Company: Uber
Difficulty: medium
Longest Arithmetic Selection Choose as many elements as possible from array A . After sorting the chosen values in nondecreasing order, every pair of consecutive values must have the same difference. If the common difference is positive, each numeric value may be chosen at most once. If it is zero, all chosen values are equal and their occurrences may all be used. Input The first line contains N . The second line contains N integers. Output Print the maximum number of chosen elements. Constraints 2 <= N <= 50 1 <= A[i] <= 100 Examples Input: 5 4 7 1 5 3 Output: 4 Input: 5 12 12 12 15 10 Output: 3 Input: 7 18 26 18 24 24 20 22 Output: 5 Notes For a positive difference, duplicate occurrences do not allow the same value to be selected more than once.