#include <bits/stdc++.h>   using namespace std;   long long spf[101];   long long fac[101];   void sieve() {     spf[1] = 1;     for (long long i = 2; i < 101; i++) spf[i] = i;     for (long long i = 4; i < 101; i += 2) spf[i] = 2;     for (long long i = 3; i * i < 101; i++) {       if (spf[i] == i) {         for (long long j = i * i; j < 101; j += i)           if (spf[j] == j) spf[j] = i;       }     }   }   map<long long, long long> getfactor(long long a) {     map<long long, long long> m;     while (a > 1) {       m[spf[a]]++;       a /= spf[a];     }     return m;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long inverse(long long a, long long p) { return power(a, p - 2, p); }   long long ncr(long long n, long long r, long long p) {     if (r == 0) return 1;     return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;   }   long long pre1[200000] = {0}, pre2[200000] = {0};   void solve() {     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) {       long long x;       cin >> x;       pre1[i] += pre1[i - 1] + (x == 1);       pre2[i] += pre2[i - 1] + (x == 2);     }     for (long long i = n + 1; i <= 150000; i++) {       pre1[i] += pre1[i - 1] + 1;       pre2[i] += pre2[i - 1] + 1;     }     vector<pair<long long, long long> > v;     for (long long i = 1; i <= n; i++) {       long long j = 0;       long long count1 = 0, count2 = 0;       long long counter = 0;       while (1) {         long long g = lower_bound(pre1 + j, pre1 + 140000, pre1[j] + i) - pre1;         long long l = lower_bound(pre2 + j, pre2 + 140000, pre2[j] + i) - pre2;         if (g == n && l > n) {           count1++;           if (count1 > count2) {             v.push_back(make_pair(count1, i));             break;           }         }         if (l == n && g > n) {           count2++;           if (count2 > count1) {             v.push_back(make_pair(count2, i));             break;           }         }         if (l > n && g > n) break;         if (l < g) {           count2++;           j = l;         } else {           count1++;           j = g;         }       }     }     sort(v.begin(), v.end());     cout << v.size() <<   n ;     for (auto it : v) cout << it.first <<     << it.second <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     while (t--) {       solve();     }   }   