using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var list = new List<(int ai, int count)>{ (a[0], 1 )}; for (var i = 1; i < n; ++i) { if (list[^1].ai == a[i]) list[^1] = (a[i], list[^1].count + 1); else list.Add((a[i], 1)); } var dp = new int[list.Count]; dp[0] = list[0].count; if (dp.Length > 1) dp[1] = list[1].count; var max = dp[0]; for (var i = 2; i < dp.Length; ++i) { dp[i] = max + list[i].count; max = Math.Max(max, dp[i - 1]); } WriteLine(dp.Max()); } }