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