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