N = int(input()) A = list(map(int,input().split())) DP = [[0] * 2 for _ in range(N)] DP[0][1] = 1 for i in range(1,N): DP[i][0] = max(DP[i-1][0], DP[i-1][1]) if A[i-1] == A[i]: DP[i][1] = max(DP[i-1][0] + 1, DP[i-1][1] + 1) else: DP[i][1] = max(DP[i-1][0] + 1, DP[i-1][1]) print(max(DP[-1]))