// Hope is a good thing, May be the best of things.. And no good thing ever dies <3
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 1e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
int ara[M], smid[M][3], csum[M][3];
int main () {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    memset(smid, oo, sizeof smid);
    cin >> n;
    for (int i = 1, x, sm1 = 0, sm2 = 0; i <= n; i++) {
        cin >> ara[i];
        if (ara[i] == 1) sm1++;
        else sm2++;
        smid[sm2][2] = min(smid[sm2][2], i);
        smid[sm1][1] = min(smid[sm1][1], i);
        csum[i][1] = sm1;
        csum[i][2] = sm2;
    }
    ll s, t;
    vector < pii > vp;
    for (t = 1; t <= n; t++) {
        int pos = 0, sm1 = 0, sm2 = 0, s1 = 0, s2 = 0;
        while (pos <= n) {
            sm1 = csum[pos][1] + t;
            sm2 = csum[pos][2] + t;
            if (smid[sm1][1] < smid[sm2][2]) {
                pos = smid[sm1][1];
                s1++;
                if (pos == n && s1 > s2) {
                    vp.pb(pii(max(s1, s2), t));
                }
            }
            else {
                pos = smid[sm2][2];
                s2++;
                if (pos == n && s1 < s2) {
                    vp.pb(pii(max(s1, s2), t));
                }
            }
            //cout << t << " " << sm1 << " " << sm2 << " " << pos << endl;
            if (pos >= n) break;
        }
    }
    sort(vp.begin(), vp.end());
    cout << vp.size() << endl;
    for (int i = 0; i < vp.size(); i++) {
        cout << vp[i].first << " " << vp[i].second << endl;
    }
    return 0;
}


// Hope is a good thing, May be the best of things.. And no good thing ever dies <3
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 1e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
int ara[M], smid[M][3], csum[M][3];
int main () {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    memset(smid, oo, sizeof smid);
    cin >> n;
    for (int i = 1, x, sm1 = 0, sm2 = 0; i <= n; i++) {
        cin >> ara[i];
        if (ara[i] == 1) sm1++;
        else sm2++;
        smid[sm2][2] = min(smid[sm2][2], i);
        smid[sm1][1] = min(smid[sm1][1], i);
        csum[i][1] = sm1;
        csum[i][2] = sm2;
    }
    ll s, t;
    vector < pii > vp;
    for (t = 1; t <= n; t++) {
        int pos = 0, sm1 = 0, sm2 = 0, s1 = 0, s2 = 0;
        while (pos <= n) {
            sm1 = csum[pos][1] + t;
            sm2 = csum[pos][2] + t;
            if (smid[sm1][1] < smid[sm2][2]) {
                pos = smid[sm1][1];
                s1++;
            }
            else {
                pos = smid[sm2][2];
                s2++;
            }
            //cout << t << " " << sm1 << " " << sm2 << " " << pos << endl;
            if (pos > n) break;
            if (pos == n) {
                if (s1 == s2) break;
                vp.pb(pii(max(s1, s2), t));
            }
        }
    }
    sort(vp.begin(), vp.end());
    cout << vp.size() << endl;
    for (int i = 0; i < vp.size(); i++) {
        cout << vp[i].first << " " << vp[i].second << endl;
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef unsigned long long ll;
typedef long double ld;
typedef unordered_set<int> usi;
typedef unordered_set<ll> usl;
typedef unordered_map<ll, int> umli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef deque<pair<int, int>> dqpi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
typedef vector<bool> vb;

int mymax(pair<int, int> p, pair<int, int> &before) {
    return max(p.first-before.first, p.second-before.second);
}

bool ge(pi out1, pi out2) {
    return (out1.first<out2.first || (out1.first==out2.first && out1.second<out2.second));
}

int find(int t, vpi &pairs, int start) {
    pair<int, int> before=pairs[start];

    int l=start+1, r=min(start+2*t, int(pairs.size()-1));
    if (mymax(pairs[r], before)<t) {
        return -1;
    }
    int mid=(l+r)/2;
    while (r-l>1) {
        mid=(l+r)/2;
        if (mymax(pairs[mid], before)>=t) {
            r=mid;
        } else if (mymax(pairs[mid], before)<t) {
            l=mid;
        }
    }
    int out=r;
    if (mymax(pairs[l], before)==t) {
        out=l;
    }
    return out;
}

int main() {

    int n, a;
    scanf("%d", &n);
    vi as;
    vpi pairs={make_pair(0, 0)};
    for (int i=0; i<n; i++) {
        scanf("%d", &a);
        as.push_back(a);
        if (a==1) {
            pairs.push_back(make_pair(pairs.back().first+1, pairs.back().second));
        } else {
            pairs.push_back(make_pair(pairs.back().first, pairs.back().second+1));
        }
    }
    if (n==1) {
        printf("%d\n%d %d", 1, 1, 1);
        return 0;
    }

    vi ss;
    vi ts;
    vpi outs;
    for (int t=1; t<=n; t++) {
//        cout << endl << "t = " << t<<endl;
        bool p=true;
        int start=0;
        int counta=0;
        int countb=0;
        while (true) {
            if (start==pairs.size()-1) {
                p=true;
                break;
            }
            start=find(t, pairs, start);
//            cout << "found " << start << endl;
            if (start==-1) {
                p=false;
                break;
            }
            if (as[start-1]==1) {
                counta++;
            } else {
                countb++;
            }

        }
        if (p) {
            if (counta!=countb) {
                if ((as.back()==1 && counta>countb) || (as.back()==2 && counta<countb)) {
                    ss.push_back(max(counta, countb));
                    ts.push_back(t);
                    outs.push_back(make_pair(max(counta, countb), t));
                }
            }
        }

    }
    sort(outs.begin(), outs.end(), ge);

    printf("%d\n", outs.size());
    for (int i=0; i<ss.size(); i++) {
        printf("%d %d\n", outs[i].first, outs[i].second);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef unsigned long long ll;
typedef long double ld;
typedef unordered_set<int> usi;
typedef unordered_set<ll> usl;
typedef unordered_map<ll, int> umli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef deque<pair<int, int>> dqpi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
typedef vector<bool> vb;

int mymax(pair<int, int> p, pair<int, int> &before) {
    return max(p.first-before.first, p.second-before.second);
}

bool ge(pi out1, pi out2) {
    return (out1.first<out2.first || (out1.first==out2.first && out1.second<out2.second));
}

int find(int t, vpi &pairs, int start) {
    pair<int, int> before=pairs[start];

    int l=start+1, r=min(start+2*t, int(pairs.size()-1));
    if (mymax(pairs[r], before)<t) {
        return -1;
    }
    int mid=(l+r)/2;
    while (r-l>1) {
        mid=(l+r)/2;
        if (mymax(pairs[mid], before)>=t) {
            r=mid;
        } else if (mymax(pairs[mid], before)<t) {
            l=mid;
        }
    }
    int out=r;
    if (mymax(pairs[l], before)==t) {
        out=l;
    }
    return out;
}

int main() {

    int n, a;
    scanf("%d", &n);
    vi as;
    vpi pairs={make_pair(0, 0)};
    for (int i=0; i<n; i++) {
        scanf("%d", &a);
        as.push_back(a);
        if (a==1) {
            pairs.push_back(make_pair(pairs.back().first+1, pairs.back().second));
        } else {
            pairs.push_back(make_pair(pairs.back().first, pairs.back().second+1));
        }
    }
    if (n==1) {
        printf("%d\n%d %d", 1, 1, 1);
        return 0;
    }

    vi ss;
    vi ts;
    vpi outs;
    for (int t=1; t<=n; t++) {
//        cout << endl << "t = " << t<<endl;
        bool p=true;
        int start=0;
        int counta=0;
        int countb=0;
        while (true) {
            if (start==pairs.size()-1) {
                p=true;
                break;
            }
            start=find(t, pairs, start);
//            cout << "found " << start << endl;
            if (start==-1) {
                p=false;
                break;
            }
            if (as[start-1]==1) {
                counta++;
            } else {
                countb++;
            }

        }
        if (p) {
            if (counta!=countb) {
                ss.push_back(max(counta, countb));
                ts.push_back(t);
                outs.push_back(make_pair(max(counta, countb), t));
            }
        }

    }
    sort(outs.begin(), outs.end(), ge);

    printf("%d\n", outs.size());
    for (int i=0; i<ss.size(); i++) {
        printf("%d %d\n", outs[i].first, outs[i].second);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef unsigned long long ll;
typedef long double ld;
typedef unordered_set<int> usi;
typedef unordered_set<ll> usl;
typedef unordered_map<ll, int> umli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef deque<pair<int, int>> dqpi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
typedef vector<bool> vb;

int mymax(pair<int, int> p, pair<int, int> &before) {
    return max(p.first-before.first, p.second-before.second);
}

int find(int t, vpi &pairs, int start) {
    pair<int, int> before=pairs[start];

    int l=start+1, r=min(start+2*t, int(pairs.size()-1));
    if (mymax(pairs[r], before)<t) {
        return -1;
    }
    int mid=(l+r)/2;
    while (r-l>1) {
        mid=(l+r)/2;
        if (mymax(pairs[mid], before)>=t) {
            r=mid;
        } else if (mymax(pairs[mid], before)<t) {
            l=mid;
        }
    }
    int out=r;
    if (mymax(pairs[l], before)==t) {
        out=l;
    }
    return out;
}

int main() {

    int n, a;
    scanf("%d", &n);
    vi as;
    vpi pairs={make_pair(0, 0)};
    for (int i=0; i<n; i++) {
        scanf("%d", &a);
        as.push_back(a);
        if (a==1) {
            pairs.push_back(make_pair(pairs.back().first+1, pairs.back().second));
        } else {
            pairs.push_back(make_pair(pairs.back().first, pairs.back().second+1));
        }
    }
    if (n==1) {
        printf("%d\n%d %d", 1, 1, 1);
        return 0;
    }

    vi ss;
    vi ts;
    for (int t=1; t<=n; t++) {
//        cout << endl << "t = " << t<<endl;
        bool p=true;
        int start=0;
        int counta=0;
        int countb=0;
        while (true) {
            if (start==pairs.size()-1) {
                p=true;
                break;
            }
            start=find(t, pairs, start);
//            cout << "found " << start << endl;
            if (start==-1) {
                p=false;
                break;
            }
            if (as[start-1]==1) {
                counta++;
            } else {
                countb++;
            }

        }
        if (p) {
            if (counta!=countb) {
                ss.push_back(max(counta, countb));
                ts.push_back(t);
            }
        }

    }
    printf("%d\n", ss.size());
    for (int i=0; i<ss.size(); i++) {
        printf("%d %d\n", ss[i], ts[i]);
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define all(x) x.begin(), x.end()
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define frn(i, a, b) for (int i = a; i >= b; i--)
#define mk make_pair
#define endl "\n"
#define setvector(i, vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 9e18;
//uncomment for accurate decimal precision.
//cout << fixed << setprecision(9);
ll bin(ve <ll> &pre, ll l, ll x)
{
    ll n=sz(pre);
    ll i=l;
    ll j=n-1;
    ll sum=0;
    if(l>0)
        sum=pre[l-1];
    while(i<j)
    {
        ll mid=(i+j)/2;
        if(pre[mid]-sum>=x)
        {
            j=mid;
        }
        else
        {
            i=mid+1;
        }
    }
    if(pre[i]-sum==x)
    {
        return i;
    }
    return inf;
}
int main()
{
    fastio
    ll n;
    cin>>n;
    ve <ll> in(n);
    inarr(i, in, n);
    ve <ll> pre1(n, 0), pre2(n, 0);
    fr(i, 0, n-1)
    {
        pre1[i]=i>0?pre1[i-1]:0;
        pre2[i]=i>0?pre2[i-1]:0;
        if(in[i]==1)
        {
            pre1[i]++;
        }
        else
        {
            pre2[i]++;
        }
    }
    ve <pair <ll,ll>> ans;
    fr(i, 1, n)
    {
        ll c1=0, c2=0;
        ll j=-1;
        while(j<n-1)
        {
            ll r1=bin(pre1, j+1, i), r2=bin(pre2, j+1, i);
            if(r1<r2)
            {
                c1++;
            }
            else
            {
                c2++;
            }
            j=min(r1, r2);
        }
        if((j==n-1)&&(c1!=c2))
        {
            ans.pb(mk(max(c1, c2), i));
        }
    }
    sort(all(ans));
    cout<<sz(ans)<<endl;
    fr(i, 0, sz(ans)-1)
    {
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define all(x) x.begin(), x.end()
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define frn(i, a, b) for (int i = a; i >= b; i--)
#define mk make_pair
#define endl "\n"
#define setvector(i, vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 9e18;
//uncomment for accurate decimal precision.
//cout << fixed << setprecision(9);
ll bin(ve <ll> &pre, ll l, ll x)
{
    ll n=sz(pre);
    ll i=l;
    ll j=n-1;
    ll sum=0;
    if(l>0)
        sum=pre[l-1];
    while(i<j)
    {
        ll mid=(i+j)/2;
        if(pre[mid]-sum>=x)
        {
            j=mid;
        }
        else
        {
            i=mid+1;
        }
    }
    if(pre[i]-sum==x)
    {
        return i;
    }
    return inf;
}
int main()
{
    fastio
    ll n;
    cin>>n;
    ve <ll> in(n);
    inarr(i, in, n);
    ve <ll> pre1(n, 0), pre2(n, 0);
    fr(i, 0, n-1)
    {
        pre1[i]=i>0?pre1[i-1]:0;
        pre2[i]=i>0?pre2[i-1]:0;
        if(in[i]==1)
        {
            pre1[i]++;
        }
        else
        {
            pre2[i]++;
        }
    }
    ve <pair <ll,ll>> ans;
    fr(i, 1, n)
    {
        ll c1=0, c2=0;
        ll j=-1;
        while(j<n-1)
        {
            ll r1=bin(pre1, j+1, i), r2=bin(pre2, j+1, i);
            if(r1<r2)
            {
                c1++;
            }
            else
            {
                c2++;
            }
            j=min(r1, r2);
        }
        if((j==n-1)&&(c1>c2))
        {
            ans.pb(mk(max(c1, c2), i));
        }
    }
    sort(all(ans));
    cout<<sz(ans)<<endl;
    fr(i, 0, sz(ans)-1)
    {
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define all(x) x.begin(), x.end()
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define frn(i, a, b) for (int i = a; i >= b; i--)
#define mk make_pair
#define endl "\n"
#define setvector(i, vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 9e18;
//uncomment for accurate decimal precision.
//cout << fixed << setprecision(9);
ll bin(ve <ll> &pre, ll l, ll x)
{
    ll n=sz(pre);
    ll i=l;
    ll j=n-1;
    ll sum=0;
    if(l>0)
        sum=pre[l-1];
    while(i<j)
    {
        ll mid=(i+j)/2;
        if(pre[mid]-sum>=x)
        {
            j=mid;
        }
        else
        {
            i=mid+1;
        }
    }
    if(pre[i]-sum==x)
    {
        return i;
    }
    return inf;
}
int main()
{
    fastio
    ll n;
    cin>>n;
    ve <ll> in(n);
    inarr(i, in, n);
    ve <ll> pre1(n, 0), pre2(n, 0);
    fr(i, 0, n-1)
    {
        pre1[i]=i>0?pre1[i-1]:0;
        pre2[i]=i>0?pre2[i-1]:0;
        if(in[i]==1)
        {
            pre1[i]++;
        }
        else
        {
            pre2[i]++;
        }
    }
    ve <pair <ll,ll>> ans;
    fr(i, 1, n)
    {
        ll c1=0, c2=0;
        ll j=-1;
        ll x1=-1;
        while(j<n-1)
        {
            ll r1=bin(pre1, j+1, i), r2=bin(pre2, j+1, i);
            if(r1<r2)
            {
                c1++;
                x1=1;
            }
            else
            {
                c2++;
                x1=2;
            }
            j=min(r1, r2);
        }
        if((j==n-1)&&(c1!=c2))
        {
            if(((c1>c2)&&(x1==1))||((c2>c1)&&(x1==2)))
            {
                ans.pb(mk(max(c1, c2), i));
            }
        }
    }
    sort(all(ans));
    cout<<sz(ans)<<endl;
    fr(i, 0, sz(ans)-1)
    {
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    }
}


#include "bits/stdc++.h"

using namespace std;
using pii = pair <int, int>;

const int mx = 2e5 + 9;

int game[2][mx];
int f_occ[2][mx];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x; scanf("%d", &x); x--;
        game[x][i]++;
    }

    memset(f_occ, -1, sizeof f_occ);
    for (auto x : {0, 1}) {
        for (int i = 1; i <= n; i++) {
            game[x][i] += game[x][i - 1];
            if (f_occ[x][game[x][i]] != -1) continue;
            f_occ[x][game[x][i]] = i;
        }
    }

    vector <pii> ans;
    for (int t = 1; t <= n; t++) {
        int s = 0;
        int last[] = {0, 0};
        int win[] = {0, 0};
        int idx = 0;
        int latest = -1;
        while (true) {
            // printf("%d\n", idx);
            int next[] = {0, 0};
            for (auto x : {0, 1}) next[x] = last[x] + t;
            int f[] = {0, 0};
            for (auto x : {0, 1}) f[x] = f_occ[x][next[x]];

            if (f[0] == -1 and f[1] == -1) break;
            if (f[0] == -1) {
                last[0] = game[0][f[1]];
                last[1] = game[1][f[1]];
                idx = f[1];
                win[1]++;
                latest = 1;
                continue;
            }

            if (f[1] == -1) {
                last[0] = game[0][f[0]];
                last[1] = game[1][f[0]];
                idx = f[0];
                win[0]++;
                latest = 0;
                continue;
            }

            if (f[0] < f[1]) {
                last[0] = game[0][f[0]];
                last[1] = game[1][f[0]];
                idx = f[0];
                win[0]++;
                latest = 0;
            } else {
                last[0] = game[0][f[1]];
                last[1] = game[1][f[1]];
                idx = f[1];
                win[1]++;
                latest = 1;
            }
        }

        if (idx != n) continue;
        if (win[0] == win[1]) continue;
        if (win[latest] < win[1 - latest]) continue;
        s = win[latest];
        ans.emplace_back(s, t);
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", (int) ans.size());
    for (auto [s, t] : ans) {
        printf("%d %d\n", s, t);
    }
}


#include "bits/stdc++.h"

using namespace std;
using pii = pair <int, int>;

const int mx = 2e5 + 9;

int game[2][mx];
int f_occ[2][mx];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x; scanf("%d", &x); x--;
        game[x][i]++;
    }

    memset(f_occ, -1, sizeof f_occ);
    for (auto x : {0, 1}) {
        for (int i = 1; i <= n; i++) {
            game[x][i] += game[x][i - 1];
            if (f_occ[x][game[x][i]] != -1) continue;
            f_occ[x][game[x][i]] = i;
        }
    }

    vector <pii> ans;
    for (int t = 1; t <= n; t++) {
        int s = 0;
        int last[] = {0, 0};
        int win[] = {0, 0};
        int idx = 0;
        while (true) {
            // printf("%d\n", idx);
            int next[] = {0, 0};
            for (auto x : {0, 1}) next[x] = last[x] + t;
            int f[] = {0, 0};
            for (auto x : {0, 1}) f[x] = f_occ[x][next[x]];

            if (f[0] == -1 and f[1] == -1) break;
            if (f[0] == -1) {
                last[0] = game[0][f[1]];
                last[1] = game[1][f[1]];
                idx = f[1];
                win[1]++;
                continue;
            }

            if (f[1] == -1) {
                last[0] = game[0][f[0]];
                last[1] = game[1][f[0]];
                idx = f[0];
                win[0]++;
                continue;
            }

            if (f[0] < f[1]) {
                last[0] = game[0][f[0]];
                last[1] = game[1][f[0]];
                idx = f[0];
                win[0]++;
            } else {
                last[0] = game[0][f[1]];
                last[1] = game[1][f[1]];
                idx = f[1];
                win[1]++;
            }
        }

        if (idx != n) continue;
        if (win[0] == win[1]) continue;
        if (win[0] > win[1]) s = win[0];
        else s = win[1];
        ans.emplace_back(s, t);
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", (int) ans.size());
    for (auto [s, t] : ans) {
        printf("%d %d\n", s, t);
    }
}


#include "bits/stdc++.h"

using namespace std;
using pii = pair <int, int>;

const int mx = 2e5 + 9;

int game[2][mx];
int f_occ[2][mx];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x; scanf("%d", &x); x--;
        game[x][i]++;
    }

    memset(f_occ, -1, sizeof f_occ);
    for (auto x : {0, 1}) {
        for (int i = 1; i <= n; i++) {
            game[x][i] += game[x][i - 1];
            if (f_occ[x][game[x][i]] != -1) continue;
            f_occ[x][game[x][i]] = i;
        }
    }

    vector <pii> ans;
    for (int t = 1; t <= n; t++) {
        int s = 0;
        int last[] = {0, 0};
        int win[] = {0, 0};
        int idx = 0;
        while (true) {
            // printf("%d\n", idx);
            int next[] = {0, 0};
            for (auto x : {0, 1}) next[x] = last[x] + t;
            int f[] = {0, 0};
            for (auto x : {0, 1}) f[x] = f_occ[x][next[x]];

            if (f[0] == -1 and f[1] == -1) break;
            if (f[0] == -1) {
                last[0] = game[0][f[1]];
                last[1] = game[1][f[1]];
                idx = f[1];
                win[1]++;
                continue;
            }

            if (f[1] == -1) {
                last[0] = game[0][f[0]];
                last[1] = game[1][f[0]];
                idx = f[0];
                win[0]++;
                continue;
            }

            if (f[0] < f[1]) {
                last[0] = game[0][f[0]];
                last[1] = game[1][f[0]];
                idx = f[0];
                win[0]++;
            } else {
                last[0] = game[0][f[1]];
                last[1] = game[1][f[1]];
                idx = f[1];
                win[1]++;
            }
        }

        if (idx != n) continue;
        if (win[0] == win[1]) continue;
        if (win[0] > win[1]) s = win[0];
        else s = win[1];
        ans.emplace_back(s, t);
    }

    printf("%d\n", (int) ans.size());
    for (auto [s, t] : ans) {
        printf("%d %d\n", s, t);
    }
}


// clang-format off
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef long double f80;
typedef pair<int, int> pii;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define INF 1000000000000000000ll
#define MOD 163577857
#define EPS 1e-7
// #define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb emplace_back
#define bitc __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (int)x.length()

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs

#ifdef bhartiya
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T>
void __p(std::vector<T> a) { cout << "{ "; for (auto p : a) __p(p); cout << "}"; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) { __p(a1); __p(a...); }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";__p(arg1);cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(; ;i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<"| ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }

ll a[100005];
ll b[100005];
void solve()
{
    ll n;
    cin>>n;
    rep(i,n)
    {
        a[i+1]=a[i];
        b[i+1]=b[i];
        ll x;
        cin>>x;
        if(x==1)
        {
            a[i+1]++;
        }
        else
            b[i+1]++;
    }
    vector<pair<ll,ll>>ans;
    for(ll t=1;t<=n;t++)
    {
        ll cur=0;
        ll last=0;
        ll i=0;
        ll a1=0;
        ll b1=0;
        ll han =1;
        ll wa=0;
        ll wb=0;
        ll lw=0;
        // trace(t);
        while(cur<n)
        {
             cur+=t-max(a1,b1);
             if(cur>n)
             {
                han=0;
                break;
             }
             a1=a[cur]-a[last];
             b1=b[cur]-b[last];
             if(max(a1,b1)==t)
             {
                last=cur;
                if(a1>b1)
                {
                    lw =1;
                    wa++;
                }
                else{
                    lw =2;
                    wb++;
                }
                a1=0;
                b1=0;
             }
             // trace(cur,wa,wb);
        }
        // trace(cur,wa,wb,han);
        if(han&&wa!=wb&&a1+b1==0)
        {
            if((wa>wb)?1:2==lw)
            ans.pb(mp(max(wa,wb),t));
        }
    }
    cout<<ans.size()<<endl;
    sort(all(ans));
    for(auto x:ans)
    {
        cout<<x.ff<<' '<<x.ss<<endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
#ifdef bhartiya
    cin.exceptions(cin.failbit);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin>>t;
    fr(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    end_routine();
}


// clang-format off
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef long double f80;
typedef pair<int, int> pii;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define INF 1000000000000000000ll
#define MOD 163577857
#define EPS 1e-7
// #define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb emplace_back
#define bitc __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (int)x.length()

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs

#ifdef bhartiya
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T>
void __p(std::vector<T> a) { cout << "{ "; for (auto p : a) __p(p); cout << "}"; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) { __p(a1); __p(a...); }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";__p(arg1);cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(; ;i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<"| ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }

ll a[100005];
ll b[100005];
void solve()
{
    ll n;
    cin>>n;
    rep(i,n)
    {
        a[i+1]=a[i];
        b[i+1]=b[i];
        ll x;
        cin>>x;
        if(x==1)
        {
            a[i+1]++;
        }
        else
            b[i+1]++;
    }
    vector<pair<ll,ll>>ans;
    for(ll t=1;t<=n;t++)
    {
        ll cur=0;
        ll last=0;
        ll i=0;
        ll a1=0;
        ll b1=0;
        ll han =1;
        ll wa=0;
        ll wb=0;
        // trace(t);
        while(cur<n)
        {
             cur+=t-max(a1,b1);
             if(cur>n)
             {
                han=0;
                break;
             }
             a1=a[cur]-a[last];
             b1=b[cur]-b[last];
             if(max(a1,b1)==t)
             {
                last=cur;
                if(a1>b1)
                    wa++;
                else
                    wb++;
                a1=0;
                b1=0;
             }
             // trace(cur,wa,wb);
        }
        // trace(cur,wa,wb,han);
        if(han&&wa!=wb&&a1+b1==0)
        {
            ans.pb(mp(max(wa,wb),t));
        }
    }
    cout<<ans.size()<<endl;
    sort(all(ans));
    for(auto x:ans)
    {
        cout<<x.ff<<' '<<x.ss<<endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
#ifdef bhartiya
    cin.exceptions(cin.failbit);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin>>t;
    fr(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    end_routine();
}


// clang-format off
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef long double f80;
typedef pair<int, int> pii;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define INF 1000000000000000000ll
#define MOD 163577857
#define EPS 1e-7
// #define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb emplace_back
#define bitc __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (int)x.length()

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs

#ifdef bhartiya
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T>
void __p(std::vector<T> a) { cout << "{ "; for (auto p : a) __p(p); cout << "}"; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) { __p(a1); __p(a...); }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";__p(arg1);cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(; ;i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<"| ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }

ll a[100005];
ll b[100005];
void solve()
{
    ll n;
    cin>>n;
    rep(i,n)
    {
        a[i+1]=a[i];
        b[i+1]=b[i];
        ll x;
        cin>>x;
        if(x==1)
        {
            a[i+1]++;
        }
        else
            b[i+1]++;
    }
    vector<pair<ll,ll>>ans;
    for(ll t=1;t<=n;t++)
    {
        ll cur=0;
        ll last=0;
        ll i=0;
        ll a1=0;
        ll b1=0;
        ll han =1;
        ll wa=0;
        ll wb=0;
        ll lw=0;
        // trace(t);
        while(cur<n)
        {
             cur+=t-max(a1,b1);
             if(cur>n)
             {
                han=0;
                break;
             }
             a1=a[cur]-a[last];
             b1=b[cur]-b[last];
             if(max(a1,b1)==t)
             {
                last=cur;
                if(a1>b1)
                {
                    lw =1;
                    wa++;
                }
                else{
                    lw =2;
                    wb++;
                }
                a1=0;
                b1=0;
             }
             // trace(cur,wa,wb);
        }
        if(han&&wa!=wb&&a1+b1==0)
        {
            if(((wa>wb)?1:2)==lw)
                ans.pb(mp(max(wa,wb),t));
        }
    }
    cout<<ans.size()<<endl;
    sort(all(ans));
    for(auto x:ans)
    {
        cout<<x.ff<<' '<<x.ss<<endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
#ifdef bhartiya
    cin.exceptions(cin.failbit);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin>>t;
    fr(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    end_routine();
}


// clang-format off
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef long double f80;
typedef pair<int, int> pii;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define INF 1000000000000000000ll
#define MOD 163577857
#define EPS 1e-7
// #define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb emplace_back
#define bitc __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (int)x.length()

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs

#ifdef bhartiya
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T>
void __p(std::vector<T> a) { cout << "{ "; for (auto p : a) __p(p); cout << "}"; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) { __p(a1); __p(a...); }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";__p(arg1);cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(; ;i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<"| ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }

ll a[100005];
ll b[100005];
void solve()
{
    ll n;
    cin>>n;
    rep(i,n)
    {
        a[i+1]=a[i];
        b[i+1]=b[i];
        ll x;
        cin>>x;
        if(x==1)
        {
            a[i+1]++;
        }
        else
            b[i+1]++;
    }
    vector<pair<ll,ll>>ans;
    for(ll t=1;t<=n;t++)
    {
        ll cur=0;
        ll last=0;
        ll i=0;
        ll a1=0;
        ll b1=0;
        ll han =1;
        ll wa=0;
        ll wb=0;
        ll lw=0;
        // trace(t);
        while(cur<n)
        {
             cur+=t-max(a1,b1);
             if(cur>n)
             {
                han=0;
                break;
             }
             a1=a[cur]-a[last];
             b1=b[cur]-b[last];
             if(max(a1,b1)==t)
             {
                last=cur;
                if(a1>b1)
                {
                    lw =1;
                    wa++;
                }
                else{
                    lw =1;
                    wb++;
                }
                a1=0;
                b1=0;
             }
             // trace(cur,wa,wb);
        }
        // trace(cur,wa,wb,han);
        if(han&&wa!=wb&&a1+b1==0)
        {
            if((wa>wb)?1:2==lw)
            ans.pb(mp(max(wa,wb),t));
        }
    }
    cout<<ans.size()<<endl;
    sort(all(ans));
    for(auto x:ans)
    {
        cout<<x.ff<<' '<<x.ss<<endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
#ifdef bhartiya
    cin.exceptions(cin.failbit);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin>>t;
    fr(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    end_routine();
}


#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define stp setprecision(20)
#define endl '\n'
int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ll n;cin>>n;
    ll a[n+1]={0},on[n+1]={0},tw[n+1]={0};
    for(ll i=1;i<=n;i++)
    {
    	cin>>a[i];
    	if(a[i]==1)
    	{
    		on[i]=on[i-1]+1;
    		tw[i]=tw[i-1];
    	}
    	else
    	{
    		on[i]=on[i-1];
    		tw[i]=tw[i-1]+1;
    	}
    }
    vpl v;
    for(ll i=1;i<=n;i++)
    {
    	ll x=i,y=i;
    	ll so=0,st=0;
    	while(1)
    	{
    		ll inon=lb(on+1,on+n+1,x)-on;
    		ll intw=lb(tw+1,tw+n+1,y)-tw;
    		if(inon<intw)
    		{
    			x=on[inon]+i;
    			y=tw[inon]+i;
    			so++;
    		}
    		if(inon>intw)
    		{
    			x=on[intw]+i;
    			y=tw[intw]+i;
    			st++;
    		}
    		if(inon==intw)
    		{
    			x=on[inon]+i;
    			y=tw[intw]+i;
    		}
    		if(inon==n+1 && intw==n)
    		{
    			if(st==so)
    				break;
    			v.pb(mp(max(st,so),i));
    			break;
    		}
    		if(inon==n && intw==n+1)
    		{
    			if(st==so)
    				break;
    			v.pb(mp(max(st,so),i));
    			break;
    		}
    		if(inon==n+1 && intw==n+1)
    			break;
    	}
    }
    sort(v.begin(), v.end());
    cout<<v.size()<<endl;
    for(ll i=0;i<v.size();i++)
    	cout<<v[i].ff<<" "<<v[i].ss<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define stp setprecision(20)
#define endl '\n'
inline void pr(ll x,ll y)
{
	vpl v;
	for(ll i=1;i<=x;i++)
	{
		if(x%i==0 && x/i!=y)
		{
			v.pb(mp(i,x/i));
		}
	}

	cout<<v.size()<<endl;
	for(ll i=0;i<v.size();i++)
		cout<<v[i].ff<<" "<<v[i].ss<<endl;
}
int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ll n;cin>>n;
    ll a[n],on=0,tw=0;
    for(ll i=0;i<n;i++)
    {
    	cin>>a[i];
    	if(a[i]==1)
    		on++;
    	else
    		tw++;
    }
    if(on==tw)
    {
    	cout<<0;return 0;
    }
    if(on>tw)
    {
    	if(a[n-1]!=1)
    	{
    		cout<<0;return 0;
    	}
    	pr(on,tw);
    }
    else
    {
    	if(a[n-1]!=2)
    	{
    		cout<<0;return 0;
    	}
    	pr(tw,on);
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define stp setprecision(20)
#define endl '\n'
int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ll n;cin>>n;
    ll a[n+1]={0},on[n+1]={0},tw[n+1]={0};
    for(ll i=1;i<=n;i++)
    {
    	cin>>a[i];
    	if(a[i]==1)
    	{
    		on[i]=on[i-1]+1;
    		tw[i]=tw[i-1];
    	}
    	else
    	{
    		on[i]=on[i-1];
    		tw[i]=tw[i-1]+1;
    	}
    }
    vpl v;
    for(ll i=1;i<=n;i++)
    {
    	ll x=i,y=i;
    	ll so=0,st=0;
    	while(1)
    	{
    		ll inon=lb(on+1,on+n+1,x)-on;
    		ll intw=lb(tw+1,tw+n+1,y)-tw;
    		if(inon<intw)
    		{
    			x=on[inon]+i;
    			y=tw[inon]+i;
    			so++;
    		}
    		if(inon>intw)
    		{
    			x=on[intw]+i;
    			y=tw[intw]+i;
    			st++;
    		}
    		if(inon==intw)
    		{
    			x=on[inon]+i;
    			y=tw[intw]+i;
    		}
    		if(inon==n+1 && intw==n)
    		{
    			if(st==so)
    				break;
    			if(so>st)
    				break;
    			v.pb(mp(max(st,so),i));
    			break;
    		}
    		if(inon==n && intw==n+1)
    		{
    			if(st==so)
    				break;
    			if(st>so)
    				break;
    			v.pb(mp(max(st,so),i));
    			break;
    		}
    		if(inon==n+1 && intw==n+1)
    			break;
    	}
    }
    sort(v.begin(), v.end());
    cout<<v.size()<<endl;
    for(ll i=0;i<v.size();i++)
    	cout<<v[i].ff<<" "<<v[i].ss<<endl;
}


#include <math.h>
#include <queue>
#include<functional>
#include<algorithm>
#include<list>
#include<deque>
#include<map>
#include <unordered_map>
#include<list>
#include<set>
#include<stack>
#include<assert.h>
#include<cstring>
#include<bitset>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)n; i >= 0; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
#include <iostream>

#define int long long int
vector<int> myScore, otherScore, myInv, otherInv;
vector<int> wins;
int check(int req){
//	DEBUG(req);
	int my= 0, other = 0;
	int mySet = 0, otherSet = 0;
	while(my + req <= myScore.back() && other + req <= otherScore.back()){
		if(myInv[my + req]  < otherInv[other + req])mySet++, my += req , other= otherScore[myInv[my]];
		else otherSet++, other += req, my = myScore[otherInv[other]];
	}
	//cout << mySet << " " << otherSet << endl;
	while(my + req <= myScore.back()){
		my += req;
		mySet++;
		other = otherScore[myInv[my]];
	}
//	cout << mySet << " " << otherSet << endl;
	if(my == myScore.back() && other == otherScore.back() && mySet > otherSet)return mySet;
	else return 0;
}

signed main(){
    FastRead;
		int n;cin >> n;
		wins.resize(n + 1);
		myScore.resize(n +1), otherScore.resize(n + 1), myInv.resize(n + 1), otherInv.resize(n + 1);
   FOR1(i, n)cin >> wins[i];
	 int a = 0, b = 0;
	 assert(wins.size() == n+1);
	 assert(wins.back() == wins[n]);

	 FOR1(i, n){
		 assert(wins[i] == 1 || wins[i] ==2);
			if(wins[i] == wins.back())a++, myInv[a] = i;
			else b++, otherInv[b] = i;
			myScore[i] = a;
			otherScore[i] = b;
		}
	 //FOR1(i, n)cout << myScore[i] << " " << myInv[i] <<endl;
	 int winner = wins.back();
	 int wins1 = 0;
	 int winsOther = 0;
	 int ans = 0;
	 set<pair<int, int>> temp;
	 for(int i = wins.size() - 1; i >= 1; i--){
			if(wins[i] == wins.back())wins1++;
			else{ winsOther++; continue;}
			if(wins1 > winsOther){
				int te;
				if((te = check(wins1)))ans++, temp.insert({te, wins1});
			}
		}
		cout << ans <<endl;
		for(pii te:temp)cout << te.first << " "  << te.second <<endl;

}


#include <math.h>
#include <queue>
#include<functional>
#include<algorithm>
#include<list>
#include<deque>
#include<map>
#include <unordered_map>
#include<list>
#include<set>
#include<stack>
#include<assert.h>
#include<cstring>
#include<bitset>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)n; i >= 0; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
#include <iostream>

#define int long long int
vector<int> myWins, otherWins;
vector<int> myScore, otherScore, myInv, otherInv;
vector<int> wins;
int check(int req){
//	DEBUG(req);
	int my= 0, other = 0;
	int mySet = 0, otherSet = 0;
	while(my + req <= myScore.back() && other + req <= otherScore.back()){
		if(myInv[my + req]  < otherInv[other + req])mySet++, my += req , other= otherScore[myInv[my]];
		else otherSet++, other += req, my = myScore[otherInv[other]];
	}
	//cout << mySet << " " << otherSet << endl;
	while(my + req <= myScore.back()){
		my += req;
		mySet++;
		other = otherScore[myInv[my]];
	}
//	cout << mySet << " " << otherSet << endl;
	if(my == myScore.back() && other == otherScore.back() && mySet > otherSet)return mySet;
	else return 0;
}

signed main(){
    FastRead;
		int n;cin >> n;
		wins.resize(n + 1);
		myScore.resize(n +1), otherScore.resize(n + 1), myInv.resize(n + 1), otherInv.resize(n + 1);
   FOR1(i, n)cin >> wins[i];
	 int a, b;
	 assert(wins.size() == n+1);
	 assert(wins.back() == wins[n]);

	 FOR1(i, n){
		 assert(wins[i] == 1 || wins[i] ==2);
			if(wins[i] == wins.back())a++, myInv[a] = i;
			else b++, otherInv[b] = i;
			myScore[i] = a;
			otherScore[i] = b;
		}
	 //FOR1(i, n)cout << myScore[i] << " " << myInv[i] <<endl;
	 int winner = wins.back();
	 int wins1 = 0;
	 int winsOther = 0;
	 int ans = 0;
	 vector<pair<int, int>> temp;
	 for(int i = wins.size() - 1; i >= 1; i--){
			if(wins[i] == wins.back())wins1++;
			else{ winsOther++; continue;}
			if(wins1 > winsOther){
				int te;
				if((te = check(wins1)))ans++, temp.push_back({te, wins1});
			}
		}
		cout << ans <<endl;
		for(pii te:temp)cout << te.first << " "  << te.second <<endl;

}


#include <math.h>
#include <queue>
#include<functional>
#include<algorithm>
#include<list>
#include<deque>
#include<map>
#include <unordered_map>
#include<list>
#include<set>
#include<stack>
#include<assert.h>
#include<cstring>
#include<bitset>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)n; i >= 0; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
#include <iostream>

#define int long long int
vector<int> myWins, otherWins;
vector<int> myScore, otherScore, myInv, otherInv;
vector<int> wins;
int check(int req){
//	DEBUG(req);
	int my= 0, other = 0;
	int mySet = 0, otherSet = 0;
	while(my + req <= myScore.back() && other + req <= otherScore.back()){
		if(myInv[my + req]  < otherInv[other + req])mySet++, my += req , other= otherScore[myInv[my]];
		else otherSet++, other += req, my = myScore[otherInv[other]];
	}
	//cout << mySet << " " << otherSet << endl;
	while(my + req <= myScore.back()){
		my += req;
		mySet++;
		other = otherScore[myInv[my]];
	}
//	cout << mySet << " " << otherSet << endl;
	if(my == myScore.back() && other == otherScore.back() && mySet > otherSet)return mySet;
	else return 0;
}

signed main(){
    FastRead;
		int n;cin >> n;
		wins.resize(n + 1);
		myScore.resize(n +1), otherScore.resize(n + 1), myInv.resize(n + 1), otherInv.resize(n + 1);
   FOR1(i, n)cin >> wins[i];
	 int a, b;
	 assert(wins.size() == n+1);
	 FOR1(i, n){
			if(wins[i] == wins.back())a++, myInv[a] = i;
			else b++, otherInv[b] = i;
			myScore[i] = a;
			otherScore[i] = b;
		}
	 //FOR1(i, n)cout << myScore[i] << " " << myInv[i] <<endl;
	 int winner = wins.back();
	 int wins1 = 0;
	 int winsOther = 0;
	 int ans = 0;
	 vector<pair<int, int>> temp;
	 for(int i = wins.size() - 1; i >= 1; i--){
			if(wins[i] == wins.back())wins1++;
			else{ winsOther++; continue;}
			if(wins1 > winsOther){
				int te;
				if((te = check(wins1)))ans++, temp.push_back({te, wins1});
			}
		}
		cout << ans <<endl;
		for(pii te:temp)cout << te.first << " "  << te.second <<endl;

}


#include <math.h>
#include <queue>
#include<functional>
#include<algorithm>
#include<list>
#include<deque>
#include<map>
#include <unordered_map>
#include<list>
#include<set>
#include<stack>
#include<assert.h>
#include<cstring>
#include<bitset>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)n; i >= 0; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
#include <iostream>

#define int long long int
vector<int> myWins, otherWins;
vector<int> myScore, otherScore, myInv, otherInv;
vector<int> wins;
int check(int req){
//	DEBUG(req);
	int my= 0, other = 0;
	int mySet = 0, otherSet = 0;
	while(my + req <= myScore.back() && other + req <= otherScore.back()){
		if(myInv[my + req]  < otherInv[other + req])mySet++, my += req , other= otherScore[myInv[my]];
		else otherSet++, other += req, my = myScore[otherInv[other]];
	}
	//cout << mySet << " " << otherSet << endl;
	while(my + req <= myScore.back()){
		my += req;
		mySet++;
		other = otherScore[myInv[my]];
	}
//	cout << mySet << " " << otherSet << endl;
	if(my == myScore.back() && other == otherScore.back() && mySet > otherSet)return mySet;
	else return 0;
}

signed main(){
    FastRead;
		int n;cin >> n;
		wins.resize(n + 1);
		myScore.resize(n +1), otherScore.resize(n + 1), myInv.resize(n + 1), otherInv.resize(n + 1);
   FOR1(i, n)cin >> wins[i];
	 int a, b;
	 FOR1(i, n){
			if(wins[i] == wins.back())a++, myInv[a] = i;
			else b++, otherInv[b] = i;
			myScore[i] = a;
			otherScore[i] = b;
		}
	 //FOR1(i, n)cout << myScore[i] << " " << myInv[i] <<endl;
	 int winner = wins.back();
	 int wins1 = 0;
	 int winsOther = 0;
	 int ans = 0;
	 vector<pair<int, int>> temp;
	 for(int i = wins.size() - 1; i >= 1; i--){
			if(wins[i] == wins.back())wins1++;
			else{ winsOther++; continue;}
			if(wins1 > winsOther){
				int te;
				if((te = check(wins1)))ans++, temp.push_back({te, wins1});
			}
		}
		cout << ans <<endl;
		for(pii te:temp)cout << te.first << " "  << te.second <<endl;

}


#include <math.h>
#include <queue>
#include<functional>
#include<algorithm>
#include<list>
#include<deque>
#include<map>
#include <unordered_map>
#include<list>
#include<set>
#include<stack>
#include<assert.h>
#include<cstring>
#include<bitset>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)n; i >= 0; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
#include <iostream>

#define int long long int
vector<int> myScore, otherScore, myInv, otherInv;
vector<int> wins;
int check(int req){
//	DEBUG(req);
	int my= 0, other = 0;
	int mySet = 0, otherSet = 0;
	while(my + req <= myScore.back() && other + req <= otherScore.back()){
		if(myInv[my + req]  < otherInv[other + req])mySet++, my += req , other= otherScore[myInv[my]];
		else otherSet++, other += req, my = myScore[otherInv[other]];
	}
	//cout << mySet << " " << otherSet << endl;
	while(my + req <= myScore.back()){
		my += req;
		mySet++;
		other = otherScore[myInv[my]];
	}
//	cout << mySet << " " << otherSet << endl;
	if(my == myScore.back() && other == otherScore.back() && mySet > otherSet)return mySet;
	else return 0;
}

signed main(){
    FastRead;
		int n;cin >> n;
		wins.resize(n + 1);
		myScore.resize(n +1), otherScore.resize(n + 1), myInv.resize(n + 1), otherInv.resize(n + 1);
   FOR1(i, n)cin >> wins[i];
	 int a = 0, b = 0;
	 assert(wins.size() == n+1);
	 assert(wins.back() == wins[n]);

	 FOR1(i, n){
		 assert(wins[i] == 1 || wins[i] ==2);
			if(wins[i] == wins.back())a++, myInv[a] = i;
			else b++, otherInv[b] = i;
			myScore[i] = a;
			otherScore[i] = b;
		}
	 //FOR1(i, n)cout << myScore[i] << " " << myInv[i] <<endl;
	 int winner = wins.back();
	 int wins1 = 0;
	 int winsOther = 0;
	 int ans = 0;
	 vector<pair<int, int>> temp;
	 for(int i = wins.size() - 1; i >= 1; i--){
			if(wins[i] == wins.back())wins1++;
			else{ winsOther++; continue;}
			if(wins1 > winsOther){
				int te;
				if((te = check(wins1)))ans++, temp.push_back({te, wins1});
			}
		}
		cout << ans <<endl;
		for(pii te:temp)cout << te.first << " "  << te.second <<endl;

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N=2e5+5;

ll n,arr[100005];

ll pos[2][200050];
ll pref[2][100005];
vector<pair<ll,ll> > ans;

int main()
{
	 FIO;

	 cin>>n;
	 for(ll i=1;i<=n;i++)
		cin>>arr[i];

	 if(arr[n]==2){
		 for(int i=1;i<=n;i++)
		 {
			 arr[i]=3-arr[i];
		 }
	 }
	 memset(pos,n+1,sizeof(pos));
	 ll cnt1=0,cnt2=0;
	 for(ll i=1;i<=n;i++)
	 {
		 if(arr[i]==1)
		 {
			 cnt1++;
			 pos[0][cnt1]=i;
			 pref[0][i]+=1;
		 }
		 else
		 {
			 cnt2++;
			 pos[1][cnt2]=i;
			 pref[1][i]+=1;
		 }
		 pref[0][i]+=pref[0][i-1];
		 pref[1][i]+=pref[1][i-1];

	 }

	 for(ll i=1;i<=cnt1;i++)
	 {
		 ll curr1=0,curr2=0;
		 ll idx=0;
		 ll c1=0,c2=0;
		 while(1)
		 {
			// cout<<i<<" "<<curr1<<" "<<curr2<<" "<<c1<<" "<<c2<<" "<<idx<<endl;
			 if(curr1+i>cnt1)
			 {
				 curr1=cnt1+1;
			 }
			 else
				curr1+=i;
			 if(curr2+i>cnt2)
			 {
				 curr2=cnt2+1;
			 }
			 else
				curr2+=i;
			 ll idx1=min(pos[0][curr1],pos[1][curr2]);

			 if(idx1>n)
				break;

			 if(pos[0][curr1]<pos[1][curr2])
			 {
				 c1++;
			 }
			 else
			 {
				 c2++;
			 }
			 idx=idx1;
			 curr1=pref[0][idx];
			 curr2=pref[1][idx];
		 }
		 if(c1>c2 && idx==(n))
		 {
			 ans.pb({c1,i});
		 }
	 }
	 sort(ans.begin(),ans.end());

	 cout<<ans.size()<<endl;
	 for(auto i:ans)
	 {
		 cout<<i.fi<<" "<<i.se<<endl;
	 }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N=2e5+5;

ll n,arr[100005];

ll pos[2][200005];
ll pref[2][100005];
vector<pair<ll,ll> > ans;

int main()
{
	 FIO;

	 cin>>n;
	 for(ll i=1;i<=n;i++)
		cin>>arr[i];

	 if(arr[n]==2){
		 for(int i=1;i<=n;i++)
		 {
			 arr[i]=3-arr[i];
		 }
	 }
	 memset(pos,n+1,sizeof(pos));
	 ll cnt1=0,cnt2=0;
	 for(ll i=1;i<=n;i++)
	 {
		 if(arr[i]==1)
		 {
			 cnt1++;
			 pos[0][cnt1]=i;
			 pref[0][i]+=1;
		 }
		 else
		 {
			 cnt2++;
			 pos[1][cnt2]=i;
			 pref[1][i]+=1;
		 }
		 pref[0][i]+=pref[0][i-1];
		 pref[1][i]+=pref[1][i-1];

	 }

	 for(ll i=1;i<=cnt1;i++)
	 {
		 ll curr1=0,curr2=0;
		 ll idx=0;
		 ll c1=0,c2=0;
		 while(1)
		 {
			// cout<<i<<" "<<curr1<<" "<<curr2<<" "<<c1<<" "<<c2<<" "<<idx<<endl;
			 ll idx1=min(pos[0][curr1+i],pos[1][curr2+i]);

			 if(idx1>n)
				break;

			 if(pos[0][curr1+i]<pos[1][curr2+i])
			 {
				 c1++;
			 }
			 else
			 {
				 c2++;
			 }
			 idx=idx1;
			 curr1=pref[0][idx];
			 curr2=pref[1][idx];
		 }
		 if(c1>c2 && idx==(n))
		 {
			 ans.pb({c1,i});
		 }
	 }
	 sort(ans.begin(),ans.end());

	 cout<<ans.size()<<endl;
	 for(auto i:ans)
	 {
		 cout<<i.fi<<" "<<i.se<<endl;
	 }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N=2e5+5;

ll n,arr[100005];

ll pos[2][200050];
ll pref[2][100005];
vector<pair<ll,ll> > ans;

int main()
{
	 FIO;

	 cin>>n;
	 for(ll i=1;i<=n;i++)
		cin>>arr[i];

	 if(arr[n]==2){
		 for(int i=1;i<=n;i++)
		 {
			 arr[i]=3-arr[i];
		 }
	 }
	 for(ll i=0;i<=200010;i++)
	 {
		 for(ll j=0;j<2;j++)
			pos[j][i]=n+2;
	 }

	  ll cnt1=0,cnt2=0;
	 for(ll i=1;i<=n;i++)
	 {
		 if(arr[i]==1)
		 {
			 cnt1++;
			 pos[0][cnt1]=i;
			 pref[0][i]+=1;
		 }
		 else
		 {
			 cnt2++;
			 pos[1][cnt2]=i;
			 pref[1][i]+=1;
		 }
		 pref[0][i]+=pref[0][i-1];
		 pref[1][i]+=pref[1][i-1];

	 }

	 for(ll i=1;i<=cnt1;i++)
	 {
		 ll curr1=0,curr2=0;
		 ll idx=0;
		 ll c1=0,c2=0;
		 while(1)
		 {
			// cout<<i<<" "<<curr1<<" "<<curr2<<" "<<c1<<" "<<c2<<" "<<idx<<endl;
			 ll idx1=min(pos[0][curr1+i],pos[1][curr2+i]);

			 if(idx1>n)
				break;

			 if(pos[0][curr1+i]<pos[1][curr2+i])
			 {
				 c1++;
			 }
			 else
			 {
				 c2++;
			 }
			 idx=idx1;
			 curr1=pref[0][idx];
			 curr2=pref[1][idx];
		 }
		 if(c1>c2 && idx==(n))
		 {
			 ans.pb({c1,i});
		 }
	 }
	 sort(ans.begin(),ans.end());

	 cout<<ans.size()<<endl;
	 for(auto i:ans)
	 {
		 cout<<i.fi<<" "<<i.se<<endl;
	 }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N=2e5+5;

ll n,arr[100005];

ll pos[2][300050];
ll pref[2][300005];
vector<pair<ll,ll> > ans;

int main()
{
	 FIO;

	 cin>>n;
	 for(ll i=1;i<=n;i++)
		cin>>arr[i];

	 if(arr[n]==2){
		 for(int i=1;i<=n;i++)
		 {
			 arr[i]=3-arr[i];
		 }
	 }
	 memset(pos,n+2,sizeof(pos));
	 ll cnt1=0,cnt2=0;
	 for(ll i=1;i<=n;i++)
	 {
		 if(arr[i]==1)
		 {
			 cnt1++;
			 pos[0][cnt1]=i;
			 pref[0][i]+=1;
		 }
		 else
		 {
			 cnt2++;
			 pos[1][cnt2]=i;
			 pref[1][i]+=1;
		 }
		 pref[0][i]+=pref[0][i-1];
		 pref[1][i]+=pref[1][i-1];

	 }

	 for(ll i=1;i<=cnt1;i++)
	 {
		 ll curr1=0,curr2=0;
		 ll idx=0;
		 ll c1=0,c2=0;
		 while(1)
		 {
			// cout<<i<<" "<<curr1<<" "<<curr2<<" "<<c1<<" "<<c2<<" "<<idx<<endl;
			 if(curr1+i>cnt1)
			 {
				 curr1=cnt1+1;
			 }
			 else
				curr1+=i;
			 if(curr2+i>cnt2)
			 {
				 curr2=cnt2+1;
			 }
			 else
				curr2+=i;
			 ll idx1=min(pos[0][curr1],pos[1][curr2]);

			 if(idx1>n)
				break;

			 if(pos[0][curr1]<pos[1][curr2])
			 {
				 c1++;
			 }
			 else
			 {
				 c2++;
			 }
			 idx=idx1;
			 curr1=pref[0][idx];
			 curr2=pref[1][idx];
		 }
		 if(c1>c2 && idx==(n))
		 {
			 ans.pb({c1,i});
		 }
	 }
	 sort(ans.begin(),ans.end());

	 cout<<ans.size()<<endl;
	 for(auto i:ans)
	 {
		 cout<<i.fi<<" "<<i.se<<endl;
	 }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N=2e5+5;

ll n,arr[100005];

ll pos[2][300050];
ll pref[2][300005];
vector<pair<ll,ll> > ans;

int main()
{
	 FIO;

	 cin>>n;
	 for(ll i=1;i<=n;i++)
		cin>>arr[i];

	 if(arr[n]==2){
		 for(int i=1;i<=n;i++)
		 {
			 arr[i]=3-arr[i];
		 }
	 }
	 memset(pos,n+2,sizeof(pos));
	 ll cnt1=0,cnt2=0;
	 for(ll i=1;i<=n;i++)
	 {
		 if(arr[i]==1)
		 {
			 cnt1++;
			 pos[0][cnt1]=i;
			 pref[0][i]+=1;
		 }
		 else
		 {
			 cnt2++;
			 pos[1][cnt2]=i;
			 pref[1][i]+=1;
		 }
		 pref[0][i]+=pref[0][i-1];
		 pref[1][i]+=pref[1][i-1];

	 }

	 pos[0][cnt1+1]=pos[1][cnt2+1]=n+2;
	 for(ll i=1;i<=cnt1;i++)
	 {
		 ll curr1=0,curr2=0;
		 ll idx=0;
		 ll c1=0,c2=0;
		 while(1)
		 {
			// cout<<i<<" "<<curr1<<" "<<curr2<<" "<<c1<<" "<<c2<<" "<<idx<<endl;
			 if(curr1+i>cnt1)
			 {
				 curr1=cnt1+1;
			 }
			 else
				curr1+=i;
			 if(curr2+i>cnt2)
			 {
				 curr2=cnt2+1;
			 }
			 else
				curr2+=i;
			 ll idx1=min(pos[0][curr1],pos[1][curr2]);

			 if(idx1>n)
				break;

			 if(pos[0][curr1]<pos[1][curr2])
			 {
				 c1++;
			 }
			 else
			 {
				 c2++;
			 }
			 idx=idx1;
			 curr1=pref[0][idx];
			 curr2=pref[1][idx];
		 }
		 if(c1>c2 && idx==(n))
		 {
			 ans.pb({c1,i});
		 }
	 }
	 sort(ans.begin(),ans.end());

	 cout<<ans.size()<<endl;
	 for(auto i:ans)
	 {
		 cout<<i.fi<<" "<<i.se<<endl;
	 }

}


#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
// #define int ll
// #define float long float
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll >
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+18
#define MAX 1234567

vecp ans;
int pre1[N]={0} , pre2[N]={0} ;
int pos1[N]={0} , pos2[N]={0} , a[N];
signed main(){
  fast;

  int n ;
  cin  >> n;

  for(int i = 1 ; i <= n ; i++){
  	  cin >> a[i];
  	  pre1[i] = pre1[i-1];
  	  pre2[i] = pre2[i-1];
  	  if(a[i] == 1) pre1[i]++, pos1[pre1[i]] = i;
  	  else pre2[i]++ , pos2[pre2[i]] = i;
  }
  for(int i = 0  ; i<=3*n ; i++){
  	if(pos1[i] == 0) pos1[i] = n + 1;
  	if(pos2[i] == 0) pos2[i] = n + 1;
  	// cout << pos1[i] << endl;
  }

  for(int k = 1 ; k <= n ; k++){
  	    int i = 0 , cnt1 = 0 , cnt2 = 0 , f = 0;
  	    int last = 0;
  	    while(i< n){
  	    	// cout << i << endl;
  	    	// cntr++;
  	    	// if(cntr > 16) break;
  	    	if(pos1[k + pre1[i]] < pos2[k + pre2[i]]){
  	    		i = pos1[k + pre1[i]];
  	    		cnt1++;
  	    		last = 1;
  	    	}
  	    	else if(pos1[k + pre1[i]] > pos2[k + pre2[i]]){
  	    		i = pos2[k + pre2[i]];
  	    		cnt2++;
  	    		last = 2;
  	    	}
  	    	else{
  	    		f = 1;
  	    		break;
  	    	}
  	   }
  	   if(!f && cnt1 != cnt2){
  	   	// cout << k << " " << abs(cnt1 - cnt2) << endl;
  	   	if(cnt1 > cnt2 && last == 1)
             ans.pb({cnt1 , k});
        else if(cnt2 > cnt1 && last == 2)
        	ans.pb({cnt2 , k});
  	   }
  }
  cout << ans.size() << endl;
  sort(ans.begin() , ans.end());
  for(int i = 0 ; i < ans.size() ; i++){
  	cout << ans[i].ff << " " << ans[i].ss << endl;
  }
}


#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
// #define int ll
// #define float long float
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll >
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+18
#define MAX 1234567

vecp ans;
int pre1[N]={0} , pre2[N]={0} ;
int pos1[N]={0} , pos2[N]={0} , a[N];
signed main(){
  fast;

  int n ;
  cin  >> n;

  for(int i = 1 ; i <= n ; i++){
  	  cin >> a[i];
  	  pre1[i] = pre1[i-1];
  	  pre2[i] = pre2[i-1];
  	  if(a[i] == 1) pre1[i]++, pos1[pre1[i]] = i;
  	  else pre2[i]++ , pos2[pre2[i]] = i;
  }
  for(int i = 0  ; i<=3*n ; i++){
  	if(pos1[i] == 0) pos1[i] = n + 1;
  	if(pos2[i] == 0) pos2[i] = n + 1;
  	// cout << pos1[i] << endl;
  }

  for(int k = 1 ; k <= n ; k++){
  	    int i = 0 , cnt1 = 0 , cnt2 = 0 , f = 0;
  	    int last = 0;
  	    while(i< n){
  	    	// cout << i << endl;
  	    	// cntr++;
  	    	// if(cntr > 16) break;
  	    	if(pos1[k + pre1[i]] < pos2[k + pre2[i]]){
  	    		i = pos1[k + pre1[i]];
  	    		cnt1++;
  	    		last = 1;
  	    	}
  	    	else if(pos1[k + pre1[i]] > pos2[k + pre2[i]]){
  	    		i = pos2[k + pre2[i]];
  	    		cnt2++;
  	    		last = 2;
  	    	}
  	    	else{
  	    		f = 1;
  	    		break;
  	    	}
  	   }
  	   if(!f && cnt1 != cnt2){
  	   	// cout << k << " " << abs(cnt1 - cnt2) << endl;
  	   	if(cnt1 > cnt2 && last == 1)
             ans.pb({cnt1 , k});
        else if(cnt2 > cnt1 && last == 2)
        	ans.pb({cnt2 , k});
  	   }
  }
  cout << ans.size() << endl;
  sort(ans.begin() , ans.end());
  for(int i = 0 ; i < ans.size() ; i++){
  	cout << ans[i].ff << " " << ans[i].ss << endl;
  }
}


#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
// #define int ll
// #define float long float
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll >
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+18
#define MAX 1234567

vecp ans;
int pre1[N]={0} , pre2[N]={0} ;
int pos1[N] , pos2[N] , a[N];
signed main(){
  fast;

  int n , one = 0 , two = 0;
  cin  >> n;
  memset(pos1 , -1 , sizeof(pos1));
  memset(pos2 , -1 , sizeof(pos2));

  for(int i = 1 ; i <= n ; i++){
  	  cin >> a[i];
  	  pre1[i] = pre1[i-1];
  	  pre2[i] = pre2[i-1];
  	  if(a[i] == 1) pre1[i]++, pos1[pre1[i]] = i;
  	  else pre2[i]++ , pos2[pre2[i]] = i;
  }
  for(int i = 0  ; i<=3*n ; i++){
  	if(pos1[i] == -1) pos1[i] = n + 1;
  	if(pos2[i] == -1) pos2[i] = n + 1;
  	// cout << pos1[i] << endl;
  }

  for(int k = 1 ; k <= n ; k++){
  	    int i = 0 , cnt1 = 0 , cnt2 = 0 , f = 0;
  	    int last = 0;
  	    while(i< n){
  	    	// cout << i << endl;
  	    	// cntr++;
  	    	// if(cntr > 16) break;
  	    	if(pos1[k + pre1[i]] < pos2[k + pre2[i]]){
  	    		i = pos1[k + pre1[i]];
  	    		cnt1++;
  	    		last = 1;
  	    	}
  	    	else if(pos1[k + pre1[i]] > pos2[k + pre2[i]]){
  	    		i = pos2[k + pre2[i]];
  	    		cnt2++;
  	    		last = 2;
  	    	}
  	    	else{
  	    		f = 1;
  	    		break;
  	    	}
  	   }
  	   if(!f && cnt1 != cnt2){
  	   	// cout << k << " " << abs(cnt1 - cnt2) << endl;
  	   	if(cnt1 > cnt2 && last == 1)
             ans.pb({cnt1 , k});
        else if(cnt2 > cnt1 && last == 2)
        	ans.pb({cnt2 , k});
  	   }
  }
  cout << ans.size() << endl;
  sort(ans.begin() , ans.end());
  for(int i = 0 ; i < ans.size() ; i++){
  	cout << ans[i].ff << " " << ans[i].ss << endl;
  }
}


#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
// #define int ll
// #define float long float
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll >
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+18
#define MAX 1234567

vecp ans;
int pre1[N]={0} , pre2[N]={0} ;
int pos1[N] , pos2[N] , a[N];
signed main(){
  fast;

  int n , one = 0 , two = 0;
  cin  >> n;
  memset(pos1 , -1 , sizeof(pos1));
  memset(pos2 , -1 , sizeof(pos2));

  for(int i = 1 ; i <= n ; i++){
  	  cin >> a[i];
  	  pre1[i] = pre1[i-1];
  	  pre2[i] = pre2[i-1];
  	  if(a[i] == 1) pre1[i]++, pos1[pre1[i]] = i;
  	  else pre2[i]++ , pos2[pre2[i]] = i;
  }
  for(int i = 0  ; i<=3*n ; i++){
  	if(pos1[i] == -1) pos1[i] = n + 1;
  	if(pos2[i] == -1) pos2[i] = n + 1;
  	// cout << pos1[i] << endl;
  }

  for(int k = 1 ; k <= n ; k++){
  	    int i = 0 , cnt1 = 0 , cnt2 = 0 , f = 0;
  	    int cntr = 0;
  	    while(i< n){
  	    	// cout << i << endl;
  	    	// cntr++;
  	    	// if(cntr > 16) break;
  	    	if(pos1[k + pre1[i]] < pos2[k + pre2[i]]){
  	    		i = pos1[k + pre1[i]];
  	    		cnt1++;
  	    	}
  	    	else if(pos1[k + pre1[i]] > pos2[k + pre2[i]]){
  	    		i = pos2[k + pre2[i]];
  	    		cnt2++;
  	    	}
  	    	else{
  	    		f = 1;
  	    		break;
  	    	}
  	   }
  	   if(!f && cnt1 != cnt2){
  	   	// cout << k << " " << abs(cnt1 - cnt2) << endl;
             ans.pb({max(cnt1 , cnt2) , k});
  	   }
  }
  cout << ans.size() << endl;
  sort(ans.begin() , ans.end());
  for(int i = 0 ; i < ans.size() ; i++){
  	cout << ans[i].ff << " " << ans[i].ss << endl;
  }
}


#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
// #define int ll
// #define float long float
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll >
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+18
#define MAX 1234567

vecp ans;
int pre1[N]={0} , pre2[N]={0} ;
int pos1[N] , pos2[N] , a[N];
signed main(){
  fast;

  int n , one = 0 , two = 0;
  cin  >> n;
  memset(pos1 , -1 , sizeof(pos1));
  memset(pos2 , -1 , sizeof(pos2));

  for(int i = 1 ; i <= n ; i++){
  	  cin >> a[i];
  	  pre1[i] = pre1[i-1];
  	  pre2[i] = pre2[i-1];
  	  if(a[i] == 1) pre1[i]++, pos1[pre1[i]] = i;
  	  else pre2[i]++ , pos2[pre2[i]] = i;
  }
  for(int i = 0  ; i<=2*n ; i++){
  	if(pos1[i] == -1) pos1[i] = n + 1;
  	if(pos2[i] == -1) pos2[i] = n + 1;
  	// cout << pos1[i] << endl;
  }

  for(int k = 1 ; k <= n ; k++){
  	    int i = 0 , cnt1 = 0 , cnt2 = 0 , f = 0;
  	    int cntr = 0;
  	    while(i< n){
  	    	// cout << i << endl;
  	    	// cntr++;
  	    	// if(cntr > 16) break;
  	    	if(pos1[k + pre1[i]] < pos2[k + pre2[i]]){
  	    		i = pos1[k + pre1[i]];
  	    		cnt1++;
  	    	}
  	    	else if(pos1[k + pre1[i]] > pos2[k + pre2[i]]){
  	    		i = pos2[k + pre2[i]];
  	    		cnt2++;
  	    	}
  	    	else{
  	    		f = 1;
  	    		break;
  	    	}
  	   }
  	   if(!f && cnt1 != cnt2){
  	   	// cout << k << " " << abs(cnt1 - cnt2) << endl;
             ans.pb({max(cnt1 , cnt2) , k});
  	   }
  }
  cout << ans.size() << endl;
  sort(ans.begin() , ans.end());
  for(int i = 0 ; i < ans.size() ; i++){
  	cout << ans[i].ff << " " << ans[i].ss << endl;
  }
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n;
short int a[N];
int cur;
vector<pair<int, int>> ans;

void check(int s, int t) {
  int ocur = 3 - cur;
  int s1 = 0, s2 = 0;
  int c1 = 0, c2 = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == cur) {
      c1++;
    } else if (a[i] == ocur) {
      c2++;
    }
    if (c1 == t) {
      s1++;
      c1 = c2 = 0;
    } else if (c2 == t) {
      s2++;
      c1 = c2 = 0;
    }
    if (s1 == s || s2 == s) break;
  }
  if (s1 != s) return;
  ans.push_back({s, t});
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n;
  vector<int> cnt(3);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  cur = a[n];
  int total = cnt[cur];
  for (int i = 1; i * i <= total; i++) {
    if (total % i == 0) {
      check(total / i, i);
      if (i * i != total) check(i, total / i);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (auto e : ans) {
    cout << e.first << " " << e.second << '\n';
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n;
short int a[N];
int cur;
vector<pair<int, int>> ans;
int pre[N][3];

int binser(int pos, int turn, int t) {
  int ret = n + 1;
  int l = pos, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (pre[mid][turn] - pre[pos - 1][turn] >= t) {
      r = mid - 1;
      ret = mid;
    } else {
      l = mid + 1;
    }
  }
  if (pre[ret][turn] - pre[pos - 1][turn] != t) return n + 1;
  return ret;
}

void check(int t) {
  int pos = 1;
  int ocur = 3 - cur;
  int s1 = 0, s2 = 0;
  while (pos <= n) {
    int id_1 = binser(pos, cur, t);
    int id_2 = binser(pos, ocur, t);
    pos = min(id_1, id_2) + 1;
    if (id_1 < id_2) {
      s1++;
    } else if (id_2 < id_1) {
      s2++;
    } else {
      return;
    }
  }
  if (s1 <= s2) return;
  ans.push_back({s1, t});
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n;
  vector<int> cnt(3);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 1; j <= 2; j++) pre[i][j] = pre[i - 1][j];
    pre[i][a[i]]++;
  }
  cur = a[n];
  int total = pre[n][cur];
  for (int i = 1; i <= total; i++) check(i);
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (auto e : ans) {
    cout << e.first << " " << e.second << '\n';
  }

  return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define nxt(x)  pos[x][sc[x]+t]
ll n, a[100100], sum[100100], pos[2][100100], t, s, w, L;
vpi ans;
int gets(int t) {
//	if (t == 26)
//		cout << t << ": ";
	int s = 0, sc[2] = { 0, }, res[2] = { 0, }, r = 0;
	for (r = 0; sc[0] + sc[1] < n; r += t) {
		if (nxt(0)!= -1 && (nxt(1) == -1 || nxt(0) < nxt(1))) {
			w = nxt(0), res[0]++,L=0;
//			if(t==26)
//			cout << "0: " << w << "\n";
		} else if (nxt(1)!= -1) {
			w = nxt(1), res[1]++,L=1;
//			if(t==26)
//			cout << "1: " << w << "\n";
		}
		else {
			if(n == 8946 && (t == 652 || t == 50)) {
				cout << "B\n";
				cout << res[0] << " " << res[1] << "\n";
				cout << w << "\n";
				cout << L << sc[0] << " " << sc[1] << "\n";
			}
			if(res[0]==res[1]||w != n-1
			||sc[L]<sc[1-L])
			return -1;
//			cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
			return max(res[0], res[1]);
		}
		sc[0] = w-sum[w]+1;
		sc[1] = sum[w];
//		cout << w << " " << res[0] << " " << res[1] << ")\n";
//		cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
//		cout << w << " " << pos[0][sc[0]+1] << " " << pos[1][sc[1]+1] << "}\n";
	}
	if(n == 8946 && (t == 652 || t == 50)) {
		cout << res[0] << " " << res[1] << "\n";
		cout << w << "\n";
		cout << L << sc[0] << " " << sc[1] << "\n";
	}
	if (res[0] == res[1] || w != n - 1 || sc[L] < sc[1 - L])
		return -1;
//	cout<< t << " : " << w << " " << sc[0] << " " << sc[1] << "\n";
	return max(res[0], res[1]);
}

int main() {
	doin();
	memset(pos, -1, sizeof pos);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i], a[i]--;
		sum[i] += a[i];
		sum[i + 1] = sum[i];
		pos[a[i]][a[i] ? sum[i] : (i - sum[i] + 1)] = i;
	}
	w = sum[n - 1] > (n - sum[n - 1]);
	for (t = 1; t <= n; t++) {
		s = gets(t);
		if (s != -1)
			ans.eb(s, t);
	}
	sort(all(ans));
	cout << ans.size() << "\n";
	for (auto i : ans)
		cout << i.first << " " << i.second << "\n";
}


#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define nxt(x)  pos[x][sc[x]+t]
ll n, a[300100], sum[300100], pos[2][300100], t, s, w, L;
vpi ans;
int gets(int t) {
//	if (t == 26)
//		cout << t << ": ";
	int s = 0, sc[2] = { 0, }, res[2] = { 0, }, r = 0;
	for (; sc[0] + sc[1] < n;) {
		if (nxt(0)!= -1 && (nxt(1) == -1 || nxt(0) < nxt(1))) {
			w = nxt(0), res[0]++,L=0;
//			if(t==26)
//			cout << "0: " << w << "\n";
		} else if (nxt(1)!= -1) {
			w = nxt(1), res[1]++,L=1;
//			if(t==26)
//			cout << "1: " << w << "\n";
		}
		else {
//			if(n == 8946 && (t == 652 || t == 50)) {
//				cout << "B\n";
//				cout << res[0] << " " << res[1] << "\n";
//				cout << w << "\n";
//				cout << L << sc[0] << " " << sc[1] << "\n";
//			}
//			if(t == 15)
//			cout << L <<  " " << res[0] << " " << res[1] << "\n";
			if(res[0]==res[1]||w != n-1
			||res[L]<res[1-L])
			return -1;
//			cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
			return max(res[0], res[1]);
		}
		sc[0] = w-sum[w]+1;
		sc[1] = sum[w];
//		cout << w << " " << res[0] << " " << res[1] << ")\n";
//		cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
//		cout << w << " " << pos[0][sc[0]+1] << " " << pos[1][sc[1]+1] << "}\n";
	}
//	if(n == 8946 && (t == 652 || t == 50)) {
//		cout << res[0] << " " << res[1] << "\n";
//		cout << w << "\n";
//		cout << L << sc[0] << " " << sc[1] << "\n";
//	}
//	if(t == 15)
//	cout << L <<  " " << res[0] << " " << res[1] << "\n";
	if (res[0] == res[1] || w != n - 1 || res[L]<res[1-L])
		return -1;
//	cout<< t << " : " << w << " " << sc[0] << " " << sc[1] << "\n";
	return max(res[0], res[1]);
}

int main() {
	doin();
	memset(pos, -1, sizeof pos);
	int time = clock();
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i], a[i]--;
		sum[i] += a[i];
		sum[i + 1] = sum[i];
		pos[a[i]][a[i] ? sum[i] : (i - sum[i] + 1)] = i;
	}
	w = sum[n - 1] > (n - sum[n - 1]);
	for (t = 1; t <= n; t++) {
		s = gets(t);
//		if((clock() - time)/CLOCKS_PER_SEC >= 1)
//			return cout << t, -1;
		if (s != -1)
			ans.eb(s, t);
	}
	sort(all(ans));
	cout << ans.size() << "\n";
	for (auto i : ans)
		cout << i.first << " " << i.second << "\n";
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define nxt(x)  pos[x][sc[x]+t]
ll n, a[100100], sum[100100], pos[2][100100], t, s, w, L;
vpi ans;
int gets(int t) {
//	if (t == 26)
//		cout << t << ": ";
	int s = 0, sc[2] = { 0, }, res[2] = { 0, }, r = 0;
	for (r = 0; sc[0] + sc[1] < n; r += t) {
		if (nxt(0)!= -1 && (nxt(1) == -1 || nxt(0) < nxt(1))) {
			w = nxt(0), res[0]++,L=0;
//			if(t==26)
//			cout << "0: " << w << "\n";
		} else if (nxt(1)!= -1) {
			w = nxt(1), res[1]++,L=1;
//			if(t==26)
//			cout << "1: " << w << "\n";
		}
		else {
			if(n == 8946 && (t == 652 || t == 50)) {
				cout << res[0] << " " << res[1] << "\n";
				cout << w << "\n";
				cout << L << sc[0] << " " << sc[1] << "\n";
			}
			if(res[0]==res[1]||w != n-1
			||sc[L]<sc[1-L])
			return -1;
//			cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
			return max(res[0], res[1]);
		}
		sc[0] = w-sum[w]+1;
		sc[1] = sum[w];
//		cout << w << " " << res[0] << " " << res[1] << ")\n";
//		cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
//		cout << w << " " << pos[0][sc[0]+1] << " " << pos[1][sc[1]+1] << "}\n";
	}
	if(n == 8946 && (t == 652 || t == 50)) {
		cout << res[0] << " " << res[1] << "\n";
		cout << w << "\n";
		cout << L << sc[0] << " " << sc[1] << "\n";
	}
	if (res[0] == res[1] || w != n - 1 || sc[L] < sc[1 - L])
		return -1;
//	cout<< t << " : " << w << " " << sc[0] << " " << sc[1] << "\n";
	return max(res[0], res[1]);
}

int main() {
	doin();
	memset(pos, -1, sizeof pos);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i], a[i]--;
		sum[i] += a[i];
		sum[i + 1] = sum[i];
		pos[a[i]][a[i] ? sum[i] : (i - sum[i] + 1)] = i;
	}
	w = sum[n - 1] > (n - sum[n - 1]);
	for (t = 1; t <= n; t++) {
		s = gets(t);
		if (s != -1)
			ans.eb(s, t);
	}
	sort(all(ans));
	cout << ans.size() << "\n";
	for (auto i : ans)
		cout << i.first << " " << i.second << "\n";
}


#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define nxt(x)  pos[x][sc[x]+t]
ll n, a[100100], sum[100100], pos[2][100100], t, s, w, L;
vpi ans;
int gets(int t) {
//	if (t == 26)
//		cout << t << ": ";
	int s = 0, sc[2] = { 0, }, res[2] = { 0, }, r = 0;
	for (; sc[0] + sc[1] < n;) {
		if (nxt(0)!= -1 && (nxt(1) == -1 || nxt(0) < nxt(1))) {
			w = nxt(0), res[0]++,L=0;
//			if(t==26)
//			cout << "0: " << w << "\n";
		} else if (nxt(1)!= -1) {
			w = nxt(1), res[1]++,L=1;
//			if(t==26)
//			cout << "1: " << w << "\n";
		}
		else {
//			if(n == 8946 && (t == 652 || t == 50)) {
//				cout << "B\n";
//				cout << res[0] << " " << res[1] << "\n";
//				cout << w << "\n";
//				cout << L << sc[0] << " " << sc[1] << "\n";
//			}
//			if(t == 15)
//			cout << L <<  " " << res[0] << " " << res[1] << "\n";
			if(res[0]==res[1]||w != n-1
			||res[L]<res[1-L])
			return -1;
//			cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
			return max(res[0], res[1]);
		}
		sc[0] = w-sum[w]+1;
		sc[1] = sum[w];
//		cout << w << " " << res[0] << " " << res[1] << ")\n";
//		cout << w << " ( " << sum[w] << " ) " << sc[0] << " " << sc[1] << "]\n";
//		cout << w << " " << pos[0][sc[0]+1] << " " << pos[1][sc[1]+1] << "}\n";
	}
//	if(n == 8946 && (t == 652 || t == 50)) {
//		cout << res[0] << " " << res[1] << "\n";
//		cout << w << "\n";
//		cout << L << sc[0] << " " << sc[1] << "\n";
//	}
//	if(t == 15)
//	cout << L <<  " " << res[0] << " " << res[1] << "\n";
	if (res[0] == res[1] || w != n - 1 || res[L]<res[1-L])
		return -1;
//	cout<< t << " : " << w << " " << sc[0] << " " << sc[1] << "\n";
	return max(res[0], res[1]);
}

int main() {
	doin();
	memset(pos, -1, sizeof pos);
	int time = 10*clock();
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i], a[i]--;
		sum[i] += a[i];
		sum[i + 1] = sum[i];
		pos[a[i]][a[i] ? sum[i] : (i - sum[i] + 1)] = i;
	}
	w = sum[n - 1] > (n - sum[n - 1]);
	for (t = 1; t <= n; t++) {
		s = gets(t);
		if((10*clock() - time) > 17*CLOCKS_PER_SEC)
			return cout << t, -1;
		if (s != -1)
			ans.eb(s, t);
	}
	sort(all(ans));
	cout << ans.size() << "\n";
	for (auto i : ans)
		cout << i.first << " " << i.second << "\n";
}