from itertools import groupby input() _ = list(map(int, input().split())) a = [len(tuple(v)) for _, v in groupby(_)] N = len(a) dp = [0]*(N+10) for i in range(N): dp[i+1] = max(dp[i], dp[i+1]) dp[i+2] = max(dp[i]+a[i], dp[i+2]) print(max(dp))