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