import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } ArrayList list = new ArrayList<>(); int prev = a[0]; int count = 0; for (int i : a) { if (i == prev) { count++; } else { list.add(count); count = 1; prev = i; } } list.add(count); list.add(0); list.add(0); list.add(0); // for (int i = 0; i < list.size(); i++) { // System.out.print(list.get(i)+" "); // } // System.out.println(); int ans = 0; for (int i = 0; i < list.size() - 3; i++) { if (list.get(i) - list.get(i + 1) >= list.get(i + 1) - list.get(i) - list.get(i + 2)) { ans += list.get(i); i++; } else { ans += list.get(i + 1); i+=2; } } System.out.println(ans); } }