using static System.Math; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); getAns(n, a); } static int calc (int n, int [] a, bool t) { var prez = t; var count = t ? 1 : 0; var pre = a[0]; for (int i = 1; i < n; i++) { if (a[i] == pre) { count++; prez = true; } else { if (prez) prez = false; else { prez = true; count++; } } pre = a[i]; } return count; } static void getAns(int n, int[] a) { var ans = Max(calc(n, a, true), calc(n, a, false)); Console.WriteLine(ans); } }