#C12405. Longest Consecutive Subsequence

    ID: 41829 Type: Default 1000ms 256MiB

Longest Consecutive Subsequence

Longest Consecutive Subsequence

Given an array of integers, find the length of the longest subsequence in which every consecutive pair of numbers differs by exactly 11. Note that the subsequence does not need to be contiguous in the original array. For example, in the array [1, 2, 3, 4, 6, 5, 7], the entire array forms a valid sequence and its length is 7.

inputFormat

The input is read from standard input. The first line contains an integer nn, representing the number of elements in the array. The second line contains nn space-separated integers.

outputFormat

Print a single integer to standard output representing the length of the longest subsequence where the difference between every two consecutive elements is exactly 11.## sample

7
1 2 3 4 6 5 7
7