Author: | A. Karabanov | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 64 Mb | |
Output file: | Standard output |
When Timofey was cleaning garage of his grandfather, he found a strange box under the workbench. There were ceramic plates of different lengths. His father explained to him that it was a measuring device that allowed you to store and transmit a length. The plates are simply placed against each other (their surfaces are polished to such an extent that they hold on to each other without breaking up) until the desired length is reached. Unfortunately, many plates were lost, so now it's possible to have only a limited set of lengths. Timofey wants to find out what is the longest range of consecutive natural numbers that can be obtained from the remaining plates.
The first line contains one integer n — the number of available plates. The second line contains n natural numbers xi — space-separated lengths of plates, sorted in non-descending order.
Print one natural number — length of longest range of consecutive natural numbers that can be obtained from the remaining plates.
1 ≤ n ≤ 100
1 ≤ xi ≤ 1000
In the example you are given five plates with lengths 1, 4, 5, 7 and 15. It's possible to obtain lengths [1], [4 .. 13], [15 .. 17], [19 .. 28], [31 .. 32] ([a .. b] means, that it's possible to obtain any length from a to b inclusive). The longest range has length equal to 10, for example range [4 .. 13] or [19 .. 28].
No. | Standard input | Standard output |
---|---|---|
1 |
|
|