import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int prev = sc.nextInt(); int count = 1; ArrayList list = new ArrayList<>(); for (int i = 1; i < n; i++) { int x = sc.nextInt(); if (x == prev) { count++; } else { list.add(count); count = 1; prev = x; } } list.add(count); int length = list.size(); int[][] dp = new int[2][length]; dp[1][0] = list.get(0); for (int i = 1; i < length; i++) { dp[1][i] = dp[0][i - 1] + list.get(i); dp[0][i] = Math.max(dp[0][i - 1], dp[1][i - 1]); } System.out.println(Math.max(dp[0][length - 1], dp[1][length - 1])); } }