A.P. Array

5

2 votes
Easy
Problem

Given an array A of length N . Find the length of longest subarray which forms an arithmetic progression  . 

For example if the array is [3,5,2,4,6,9] then subarray [2,4,6]  forms an  A.P. with common difference 2 having maximum length 3 .


INPUT

First line of input contains one integer N number of elements in array.

Second line contains N elements  .


OUTPUT

Print the length of longest arithmetic subarray .


CONSTRAINTS

2N106

106A[i]106

 

Sample Input
10
-1 0 1 3 4 -5 -6 -7 -8 -7
Sample Output
4
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?