from functools import reduce from fractions import gcd import math import bisect import itertools import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline INF = float("inf") # 処理内容 def main(): N = int(input()) A = list(map(int, input().split())) dp = [1] * N for i in range(N-1): if A[i] == A[i+1]: dp[i+1] = max(dp[i+1], dp[i] + 1) if i+2 < N: dp[i+2] = max(dp[i+2], dp[i] + 1) print(dp[N-1]) if __name__ == '__main__': main()