MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from heapq import heapify,heappush,heappop def main(): n = int(input()) a = list(map(int,input().split())) + [-1] dp = [[0] * 2 for _ in range(n)] dp[0][0] = 0 dp[0][1] = 1 for i in range(1,n): if a[i] == a[i - 1]: dp[i][1] = dp[i - 1][1] + 1 dp[i][0] = dp[i - 1][1] else: dp[i][1] = dp[i - 1][0] + 1 dp[i][0] = dp[i - 1][1] print(max(dp[-1])) if __name__ =='__main__': main()