def solve(): N = int(input()) A = list(map(int, input().split())) dif = [0]*(N-1) for i in range(N-1): dif[i] = A[i+1]-A[i] lis = [1] ans = 0 i = 1 while i0: lis[-1] += 1 elif dif[i]*dif[i-1]<0: lis.append(1) else: for j in range(len(lis)-1): ans = max(ans, min(lis[j],lis[j+1])) lis = [1] i += 1 i += 1 for j in range(len(lis)-1): ans = max(ans, min(lis[j],lis[j+1])) return ans print(solve())