A postal sorting facility scans
Find the length of the longest run of consecutive integers that all appear somewhere among the scanned tracking numbers (the run itself does not need to appear in any particular order in the input; only every value in some consecutive integer range needs to be present at least once).
The first line contains a single integer KaTeX can only parse string typed expression — the number of tracking numbers scanned. If KaTeX can only parse string typed expression, none were scanned.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression.
Print a single integer — the length of the longest run of consecutive integers present among the scanned numbers.
Input
6
100 4 200 1 3 2Output4ExplanationThe numbers KaTeX can only parse string typed expression are all present, forming a consecutive run of length 4. KaTeX can only parse string typed expression and KaTeX can only parse string typed expression are isolated.
Example 2:
Input
4
100 200 300 400Output1ExplanationNone of these numbers are consecutive to each other, so the longest run is just a single number, length 1.
Example 3:
Input
5
5 5 5 5 5Output1ExplanationEvery scanned number is the same value, so the longest consecutive run is still just length 1 (duplicates don't extend a run).