#C12405. Longest Consecutive Subsequence
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 . 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 , representing the number of elements in the array. The second line contains 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 .## sample
7
1 2 3 4 6 5 7
7