N=range(int(input())) A=list(map(int,input().split())) print(max(j-i+1for i in N for j in N if len(set(A[k+1]-A[k]for k in range(i,j)))<2))