#K63877. Longest Consecutive Sequence

    ID: 31851 Type: Default 1000ms 256MiB

Longest Consecutive Sequence

Longest Consecutive Sequence

Given an array of integers, your task is to determine the length of the longest sequence of consecutive integers present in the array. A consecutive sequence is defined as a set of integers that can be represented as (a, a+1, a+2, \ldots, a+k) for some integer (a).

For example, in the array [100, 4, 200, 1, 3, 2], the longest consecutive sequence is [1, 2, 3, 4] which has a length of 4.

Your solution should read input from stdin and output the answer to stdout.

inputFormat

The input begins with an integer (n) representing the number of elements in the array. The next line contains (n) space-separated integers.

outputFormat

Output a single integer denoting the length of the longest consecutive sequence in the array.## sample

0
0