import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class CF283D {

    private static class Node {
        public static final Node ZERO = new Node(0, 0);

        int ones = 0;
        int twos = 0;

        public Node(final int ones, final int twos) {
            this.ones = ones;
            this.twos = twos;
        }

        public Node sum(final Node n) {
            return new Node(ones + n.ones, twos + n.twos);
        }

    }

    private static class Result implements Comparable<Result> {
        Integer s;
        Integer t;

        public Result(final Integer s, final Integer t) {
            this.s = s;
            this.t = t;
        }

        @Override
        public int compareTo(final Result o) {

            if (s.compareTo(o.s) == 0) {
                return t.compareTo(o.t);
            }

            return s.compareTo(o.s);
        }
    }

    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] s = new int[n];
        int ones = 0;
        int twos = 0;
        for (int i = 0; i < s.length; i++) {
            s[i] = sc.nextInt();
            if (s[i] == 1) {
                ones++;
            } else {
                twos++;
            }
        }

        List<Result> result = new LinkedList<Result>();

        if (ones != twos) {
            if (ones > twos && s[n - 1] == 1) {
                result.add(new Result(ones, 1));
            }

            if (twos > ones && s[n - 1] == 2) {
                result.add(new Result(twos, 1));
            }

        }

        Node[] segTree = new Node[4 * n];

        build(segTree, s, 1, 0, n - 1);

        for (int t = 2; t <= n; t++) {
            int curr = 0;
            ones = 0;
            twos = 0;

            while (curr < n) {
                int start = curr + t - 1;
                int end = start + t - 1;

                boolean found = false;
                int mid = (start + end) / 2;
                while (start <= end) {
                    mid = (start + end) / 2;
                    if (mid < n) {
                        Node status = sum(segTree, 1, 0, n - 1, curr, mid);

                        if (status.ones == t) {
                            if (status.twos < t && s[mid] == 1) {
                                found = true;
                                ones++;
                            }

                            break;
                        } else if (status.twos == t) {
                            if (status.ones < t && s[mid] == 2) {
                                found = true;
                                twos++;
                            }

                            break;
                        } else if (status.ones > t || status.twos > t) {
                            end = mid - 1;
                        } else {
                            start = mid + 1;
                        }
                    } else {
                        end = mid - 1;
                    }
                }

                if (!found) {
                    break;
                }

                curr = mid + 1;

            }

            if (curr == n && ones != twos) {
                result.add(new Result(Math.max(ones, twos), t));
            }
        }

        Result[] res = result.toArray(new Result[0]);
        Arrays.sort(res);

        StringBuilder sb = new StringBuilder();
        for (Result r : res) {
            if (sb.length() > 0) {
                sb.append("\n");
            }

            sb.append(r.s + " " + r.t);
        }

        System.out.println(res.length);
        if (res.length > 0) {
            System.out.println(sb.toString());
        }

    }

    static void build(final Node[] tree, final int[] a, final int v, final int tl, final int tr) {
        if (tl == tr) {
            tree[v] = (a[tl] == 1 ? new Node(1, 0) : new Node(0, 1));
        } else {
            int tm = (tl + tr) / 2;
            build(tree, a, v * 2, tl, tm);
            build(tree, a, v * 2 + 1, tm + 1, tr);
            tree[v] = tree[v * 2].sum(tree[v * 2 + 1]);
        }
    }

    static Node sum(final Node[] tree, final int v, final int tl, final int tr, final int l, final int r) {
        if (l > r) {
            return Node.ZERO;
        }

        if (l == tl && r == tr) {
            return tree[v];
        }

        int tm = (tl + tr) / 2;
        return sum(tree, v * 2, tl, tm, l, Math.min(r, tm)).sum(sum(tree, v * 2 + 1, tm + 1, tr, Math.max(l, tm + 1),
                    r));

    }
}


import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class CF283D {

    private static class Node {
        public static final Node ZERO = new Node(0, 0);

        int ones = 0;
        int twos = 0;

        public Node(final int ones, final int twos) {
            this.ones = ones;
            this.twos = twos;
        }

        public Node sum(final Node n) {
            return new Node(ones + n.ones, twos + n.twos);
        }

    }

    private static class Result implements Comparable<Result> {
        Integer s;
        Integer t;

        public Result(final Integer s, final Integer t) {
            this.s = s;
            this.t = t;
        }

        @Override
        public int compareTo(final Result o) {

            if (s.compareTo(o.s) == 0) {
                return t.compareTo(o.t);
            }

            return s.compareTo(o.s);
        }
    }

    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] s = new int[n];
        int ones = 0;
        int twos = 0;
        for (int i = 0; i < s.length; i++) {
            s[i] = sc.nextInt();
            if (s[i] == 1) {
                ones++;
            } else {
                twos++;
            }
        }

        List<Result> result = new LinkedList<Result>();

        if (ones != twos) {
            result.add(new Result(Math.max(ones, twos), 1));
        }

        Node[] segTree = new Node[4 * n];

        build(segTree, s, 1, 0, n - 1);

        for (int t = 2; t <= n; t++) {
            int curr = 0;
            ones = 0;
            twos = 0;

            while (curr < n) {
                int start = curr + t - 1;
                int end = start + t - 1;

                boolean found = false;
                int mid = (start + end) / 2;
                while (start <= end) {
                    mid = (start + end) / 2;
                    if (mid < n) {
                        Node status = sum(segTree, 1, 0, n - 1, curr, mid);

                        if (status.ones == t && status.twos < t) {
                            found = true;
                            ones++;
                            break;
                        } else if (status.twos == t && status.ones < t) {
                            found = true;
                            twos++;
                            break;
                        } else if (status.ones > t || status.twos > t) {
                            end = mid - 1;
                        } else {
                            start = mid + 1;
                        }
                    } else {
                        end = mid - 1;
                    }
                }

                if (!found) {
                    break;
                }

                curr = mid + 1;

            }

            if (curr == n && ones != twos) {
                result.add(new Result(Math.max(ones, twos), t));
            }
        }

        Result[] res = result.toArray(new Result[0]);
        Arrays.sort(res);

        StringBuilder sb = new StringBuilder();
        for (Result r : res) {
            if (sb.length() > 0) {
                sb.append("\n");
            }

            sb.append(r.s + " " + r.t);
        }

        System.out.println(res.length);
        if (res.length > 0) {
            System.out.println(sb.toString());
        }

    }

    static void build(final Node[] tree, final int[] a, final int v, final int tl, final int tr) {
        if (tl == tr) {
            tree[v] = (a[tl] == 1 ? new Node(1, 0) : new Node(0, 1));
        } else {
            int tm = (tl + tr) / 2;
            build(tree, a, v * 2, tl, tm);
            build(tree, a, v * 2 + 1, tm + 1, tr);
            tree[v] = tree[v * 2].sum(tree[v * 2 + 1]);
        }
    }

    static Node sum(final Node[] tree, final int v, final int tl, final int tr, final int l, final int r) {
        if (l > r) {
            return Node.ZERO;
        }

        if (l == tl && r == tr) {
            return tree[v];
        }

        int tm = (tl + tr) / 2;
        return sum(tree, v * 2, tl, tm, l, Math.min(r, tm)).sum(sum(tree, v * 2 + 1, tm + 1, tr, Math.max(l, tm + 1),
                    r));

    }
}


import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class CF283D {

    private static class Node {
        public static final Node ZERO = new Node(0, 0);

        int ones = 0;
        int twos = 0;

        public Node(final int ones, final int twos) {
            this.ones = ones;
            this.twos = twos;
        }

        public Node sum(final Node n) {
            return new Node(ones + n.ones, twos + n.twos);
        }

    }

    private static class Result implements Comparable<Result> {
        Integer s;
        Integer t;

        public Result(final Integer s, final Integer t) {
            this.s = s;
            this.t = t;
        }

        @Override
        public int compareTo(final Result o) {

            if (s.compareTo(o.s) == 0) {
                return t.compareTo(o.t);
            }

            return s.compareTo(o.s);
        }
    }

    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] s = new int[n];
        int ones = 0;
        int twos = 0;
        for (int i = 0; i < s.length; i++) {
            s[i] = sc.nextInt();
            if (s[i] == 1) {
                ones++;
            } else {
                twos++;
            }
        }

        List<Result> result = new LinkedList<Result>();

        if (ones != twos) {
            result.add(new Result(Math.max(ones, twos), 1));
        }

        Node[] segTree = new Node[4 * n];

        build(segTree, s, 1, 0, n - 1);

        for (int t = 2; t <= n; t++) {
            int curr = 0;
            ones = 0;
            twos = 0;

            while (curr < n) {
                int start = curr + t - 1;
                int end = curr + t + t - 2;

                boolean found = false;
                int mid = (start + end) / 2;
                while (start <= end) {
                    mid = (start + end) / 2;
                    if (mid < n) {
                        Node status = sum(segTree, 1, 0, n - 1, curr, mid);

                        if (status.ones == t && status.twos < t) {
                            found = true;
                            ones++;
                            break;
                        } else if (status.twos == t && status.ones < t) {
                            found = true;
                            twos++;
                            break;
                        } else if (status.ones > t || status.twos > t) {
                            end = mid - 1;
                        } else {
                            start = mid + 1;
                        }
                    } else {
                        end = mid - 1;
                    }
                }

                if (!found) {
                    break;
                }

                curr = mid + 1;

            }

            if (curr == n && ones != twos) {
                result.add(new Result(Math.max(ones, twos), t));
            }
        }

        Result[] res = result.toArray(new Result[0]);
        Arrays.sort(res);

        StringBuilder sb = new StringBuilder();
        for (Result r : res) {
            if (sb.length() > 0) {
                sb.append("\n");
            }

            sb.append(r.s + " " + r.t);
        }

        System.out.println(res.length);
        if (res.length > 0) {
            System.out.println(sb.toString());
        }

    }

    static void build(final Node[] tree, final int[] a, final int v, final int tl, final int tr) {
        if (tl == tr) {
            tree[v] = (a[tl] == 1 ? new Node(1, 0) : new Node(0, 1));
        } else {
            int tm = (tl + tr) / 2;
            build(tree, a, v * 2, tl, tm);
            build(tree, a, v * 2 + 1, tm + 1, tr);
            tree[v] = tree[v * 2].sum(tree[v * 2 + 1]);
        }
    }

    static Node sum(final Node[] tree, final int v, final int tl, final int tr, final int l, final int r) {
        if (l > r) {
            return Node.ZERO;
        }

        if (l == tl && r == tr) {
            return tree[v];
        }

        int tm = (tl + tr) / 2;
        return sum(tree, v * 2, tl, tm, l, Math.min(r, tm)).sum(sum(tree, v * 2 + 1, tm + 1, tr, Math.max(l, tm + 1),
                    r));

    }
}


import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class CF283D1 {

    private static class Result implements Comparable<Result> {
        Integer s;
        Integer t;

        public Result(final Integer s, final Integer t) {
            this.s = s;
            this.t = t;
        }

        @Override
        public int compareTo(final Result o) {

            if (s.compareTo(o.s) == 0) {
                return t.compareTo(o.t);
            }

            return s.compareTo(o.s);
        }
    }

    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        List<Integer> posOnesList = new LinkedList<Integer>();
        List<Integer> posTwosList = new LinkedList<Integer>();
        int[] meetOnes = new int[n];
        int[] meetTwos = new int[n];
        int last = -1;
        for (int i = 0; i < n; i++) {
            int curr = sc.nextInt();
            meetOnes[i] = i > 0 ? meetOnes[i - 1] : 0;
            meetTwos[i] = i > 0 ? meetTwos[i - 1] : 0;
            if (curr == 1) {
                posOnesList.add(i);
                meetOnes[i]++;
            } else {
                posTwosList.add(i);
                meetTwos[i]++;
            }

            if (i == n - 1) {
                last = curr;
            }
        }

        Integer[] posOnes = posOnesList.toArray(new Integer[0]);
        Integer[] posTwos = posTwosList.toArray(new Integer[0]);

        List<Result> results = new LinkedList<Result>();

        for (int t = 1; t <= n; t++) {

            int currPos = -1;
            int onesWins = 0;
            int twosWins = 0;
            while (currPos < n) {
                int metOnes = currPos >= 0 ? meetOnes[currPos] : 0;
                int metTwos = currPos >= 0 ? meetTwos[currPos] : 0;

                int i1 = 3 * n;
                if (metOnes + t - 1 < posOnes.length) {
                    i1 = posOnes[metOnes + t - 1];
                }

                int i2 = 3 * n;
                if (metTwos + t - 1 < posTwos.length) {
                    i2 = posTwos[metTwos + t - 1];
                }

                if (i1 < i2) {
                    currPos = i1;
                    onesWins++;
                } else if (i2 < i1) {
                    currPos = i2;
                    twosWins++;
                } else {
                    break;
                }

            }

            if (currPos == n - 1 && onesWins != twosWins) {
                if (onesWins > twosWins && last == 1) {
                    results.add(new Result(onesWins, t));
                }

                if (twosWins > onesWins && last == 2) {
                    results.add(new Result(twosWins, t));
                }

            }

        }

        Result[] res = results.toArray(new Result[0]);
        Arrays.sort(res);

        StringBuilder sb = new StringBuilder();
        for (Result r : res) {
            if (sb.length() > 0) {
                sb.append("\n");
            }

            sb.append(r.s + " " + r.t);
        }

        System.out.println(res.length);
        if (res.length > 0) {
            System.out.println(sb.toString());
        }

    }
}


import java.util.Scanner;
import java.util.List;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author 你猜
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskD {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] winner = new int[n];
        int[] numPetyaWins = new int[n + 1];
        for (int i = 0; i < n; ++i) {
            winner[i] = in.nextInt();
            numPetyaWins[i + 1] = numPetyaWins[i];
            if (winner[i] == 1) {
                ++numPetyaWins[i + 1];
            }
        }
        int lastWin = 0;
        List<int[]> answer = new ArrayList<int[]>();
        outer: for (int setUnit = 1; setUnit <= n; ++setUnit) {
            int win1 = 0, win2 = 0;
            for (int i = 0; i < n; ) {
                int left = i, right = n - 1;
                while (left < right) {
                    int mid = ((left + right) >> 1) + 1;
                    if (numPetyaWins[mid] - numPetyaWins[i] >= setUnit
                            || mid - i - (numPetyaWins[mid] - numPetyaWins[i]) >= setUnit) {
                        right = mid - 1;
                    } else {
                        left = mid;
                    }
                }
                if (numPetyaWins[left + 1] - numPetyaWins[i] == setUnit) {
                    ++win1;
                    lastWin = 1;
                } else if (left + 1 - i - (numPetyaWins[left + 1] - numPetyaWins[i]) == setUnit) {
                    ++win2;
                    lastWin = 2;
                } else continue outer;

                i = left + 1;
            }
            if (win1 > win2 && lastWin == 1 || win1 < win2 && lastWin == 2) {
                answer.add(new int[]{Math.max(win1, win2), setUnit});
            }
        }
        Collections.sort(answer, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if (o1[0] != o2[0]) {
                    return o1[0] - o2[0];
                }
                return o1[1] - o2[1];
            }
        });
        out.println(answer.size());
        for (int[] answerItem : answer) {
            out.println(answerItem[0] + " " + answerItem[1]);
        }
    }
}


import java.util.Scanner;
import java.util.List;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author 你猜
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskD {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] winner = new int[n];
        int[] numPetyaWins = new int[n + 1];
        for (int i = 0; i < n; ++i) {
            winner[i] = in.nextInt();
            numPetyaWins[i + 1] = numPetyaWins[i];
            if (winner[i] == 1) {
                ++numPetyaWins[i + 1];
            }
        }
        List<int[]> answer = new ArrayList<int[]>();
        outer: for (int setUnit = 1; setUnit <= n; ++setUnit) {
            int win1 = 0, win2 = 0;
            for (int i = 0; i < n; ) {
                int left = i, right = n - 1;
                while (left < right) {
                    int mid = ((left + right) >> 1) + 1;
                    if (numPetyaWins[mid] - numPetyaWins[i] >= setUnit
                            || mid - i - (numPetyaWins[mid] - numPetyaWins[i]) >= setUnit) {
                        right = mid - 1;
                    } else {
                        left = mid;
                    }
                }
                if (numPetyaWins[left + 1] - numPetyaWins[i] == setUnit) {
                    ++win1;
                } else if (left + 1 - i - (numPetyaWins[left + 1] - numPetyaWins[i]) == setUnit) {
                    ++win2;
                } else continue outer;

                i = left + 1;
            }
            if (win1 != win2) {
                answer.add(new int[]{Math.max(win1, win2), setUnit});
            }
        }
        Collections.sort(answer, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if (o1[0] != o2[0]) {
                    return o1[0] - o2[0];
                }
                return o1[1] - o2[1];
            }
        });
        out.println(answer.size());
        for (int[] answerItem : answer) {
            out.println(answerItem[0] + " " + answerItem[1]);
        }
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Solution
{
    static class an implements Comparable<an> {
        int s,t;
        public an(int s, int t) {
            this.s=s;
            this.t=t;
        }
        public int compareTo(an o){
            if (s!=o.s) return s-o.s;
            return t-o.t;
        }
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner in = new Scanner(System.in);
        int n=Integer.parseInt(in.nextLine());
        String[] a=in.nextLine().split(" ");
        //for (int i=0;i<n;i++) System.out.println(a[i]);
        int[][] ct=new int[2][n+1];
        ct[0][0]=0;
        ct[1][0]=0;
        for(int i=1;i<=n;i++){
            if(a[i-1].equals("1")){
                ct[0][i]=ct[0][i-1]+1;
                ct[1][i]=ct[1][i-1];
            }
            else{
                ct[0][i]=ct[0][i-1];
                ct[1][i]=ct[1][i-1]+1;
            }
        }
        //for (int i=0;i<=n;i++) System.out.println(ct[0][i]+" "+ct[1][i]);
        ArrayList<an> ans = new ArrayList<an>();
        for(int t=1;t<=n;t++) {
            int[] w={0,0};
            int i=0;
            int wl=0;
            while(i<n){
                int l=i;
                int r=Math.min(n,l+2*t);
                while(l+1<r){
                    int m=(l+r)/2;
                    int w1=ct[0][m]-ct[0][i];
                    int w2=ct[1][m]-ct[1][i];
                    if(Math.max(w1,w2)<t) l=m;
                    else r=m;
                }
                int w1=ct[0][r]-ct[0][i];
                int w2=ct[1][r]-ct[1][i];
                if (w1==t) {
                    w[0]+=1;
                    wl=1;
                }
                else if (w2==t) {
                    w[1]+=1;
                    wl=2;
                }
                else break;
                i=r;
            }
            if (i!=n || w[0]==w[1]) continue;
            int s=Math.max(w[0],w[1]);
            if (wl==1 && s!=w[0]) continue;
            if (wl==2 && s!=w[1]) continue;
            ans.add(new an(s,t));
        }
        Collections.sort(ans);
        System.out.println(ans.size());
        for (an i: ans) System.out.println(i.s+" "+i.t);
    }
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n, a, b, val1, val2, s, k1, k2, a1, a2;
    bool first;
    cin>>n;

    int arr[n+1], one1[n+1], two1[n+1];
    map<int, int> one, two;
    for(int i=1 ; i<=n ; i++){
        cin>>arr[i];
    }
    if(arr[n] == 1)
        first = true;
    else
        first = false;

    a = 0, b = 0;
    for(int i=1 ; i<=n ; i++){
        if(arr[i] == 1){
            one[++a] = i;
        } else {
            two[++b] = i;
        }
        one1[i] = a;
        two1[i] = b;
    }

    vector<pair<int, int> > answer;

    for(int t=n ; t>=1 ; t--){
        s = 0;
        val1 = t;
        val2 = t;
        k1 = k2 = a1 = a2 = 0;
        while(s<=(n/t)){
            a1 = a;
            a2 = b;

            a = one[val1];
            b = two[val2];

            if(a == 0 && b != 0){
                val2 = val2 + t;
                k2++;
            } else if(b == 0 && a != 0){
                val1 = val1 + t;
                k1++;
            } else if(a<b){
                val2 = two1[a] + t;
                val1 = val1 + t;
                k1++;
            } else if(b<a){
                val1 = one1[b] + t;
                val2 = val2 + t;
                k2++;
            } else {
                break;
            }

            if(a == 0 && b == 0)
                break;

            s++;
        }

        if(first){
            if(a1 == n && a2 == 0 && k1>k2){
                answer.push_back(make_pair(k1, t));
            }
        } else {
            if(a2 == n && a1 == 0 && k2>k1){
                answer.push_back(make_pair(k2, t));
            }
        }
    }

    cout<<answer.size()<<endl;
    sort(answer.begin(), answer.end());

    for(int i=0 ; i<answer.size() ; i++){
        cout<<answer[i].first<<" "<<answer[i].second<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int binarySearch(int a[], int n, int lo, int hi, int val){
    int mid;
    while(lo<hi){
        mid = lo + (hi - lo)/2;
        if(a[mid] == val){
            return mid;
        } else if(a[mid] > val){
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }

    return n+1;
}

int main(){
    int n, a, b, val1, val2, s, k1, k2;
    bool first;
    cin>>n;

    int arr[n+1], one1[n+1], two1[n+1];
    map<int, int> one, two;
    for(int i=1 ; i<=n ; i++){
        cin>>arr[i];
    }
    if(arr[n] == 1)
        first = true;
    else
        first = false;

    a = 0, b = 0;
    for(int i=1 ; i<=n ; i++){
        if(arr[i] == 1){
            one[++a] = i;
        } else {
            two[++b] = i;
        }
        one1[i] = a;
        two1[i] = b;
    }

    vector<pair<int, int> > answer;

    for(int t=1 ; t<=n ; t++){
        s = 0;
        val1 = t;
        val2 = t;
        k1 = k2 = 0;
        while(s<=(n/t)){
            a = one[val1];
            b = two[val2];

            //cout<<a<<" "<<b<<endl;

            if(a == n || b == n)
                break;

            if(a==0 && b == 0)
                break;

            if(a == 0 && b != 0){
                val2 = val2 + t;
                k2++;
            } else if(b == 0 && a != 0){
                val1 = val1 + t;
                k1++;
            } else if(a<b){
                val2 = two1[val1] + t;
                val1 = val1 + t;
                k1++;
            } else {
                val1 = one1[val2] + t;
                val2 = val2 + t;
                k2++;
            }

            s++;
        }

        if(a == 0 && b!=0)
            k2++;
        else if(b == 0 && a!=0)
            k1++;
        else if(a<b)
            k1++;
        else if(b>a)
            k2++;

        if(a==n && b!=0)
            k1++;
        if(b==n && a!=0)
            k2++;

        if(first){
            if(a == n && k1>k2){
                answer.push_back(make_pair(k1, t));
            }
        } else {
            if(b == n && k2>k1){
                answer.push_back(make_pair(k2, t));
            }
        }
    }

    cout<<answer.size()<<endl;

    for(int i=0 ; i<answer.size() ; i++){
        cout<<answer[i].first<<" "<<answer[i].second<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int binarySearch(int a[], int n, int lo, int hi, int val){
    int mid;
    while(lo<hi){
        mid = lo + (hi - lo)/2;
        if(a[mid] == val){
            return mid;
        } else if(a[mid] > val){
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }

    return n+1;
}

int main(){
    int n, a, b, val1, val2, s, k1, k2, a1, a2;
    bool first;
    cin>>n;

    int arr[n+1], one1[n+1], two1[n+1];
    map<int, int> one, two;
    for(int i=1 ; i<=n ; i++){
        cin>>arr[i];
    }
    if(arr[n] == 1)
        first = true;
    else
        first = false;

    a = 0, b = 0;
    for(int i=1 ; i<=n ; i++){
        if(arr[i] == 1){
            one[++a] = i;
        } else {
            two[++b] = i;
        }
        one1[i] = a;
        two1[i] = b;
    }

    vector<pair<int, int> > answer;

    for(int t=n ; t>=1 ; t--){
        s = 0;
        val1 = t;
        val2 = t;
        k1 = k2 = a1 = a2 = 0;
        //cout<<t<<" : "<<endl;
        while(s<=(n/t)){
            a1 = a;
            a2 = b;

            a = one[val1];
            b = two[val2];

            //cout<<a<<" "<<b<<" -> "<<val1<<" "<<val2<<endl;

            if(a == 0 && b != 0){
                val2 = val2 + t;
                k2++;
            } else if(b == 0 && a != 0){
                val1 = val1 + t;
                k1++;
            } else if(a<b){
                val2 = two1[a] + t;
                val1 = val1 + t;
                k1++;
            } else if(b<a){
                val1 = one1[b] + t;
                val2 = val2 + t;
                k2++;
            } else {
                break;
            }

            if(a == 0 && b == 0)
                break;

            s++;
        }

        //cout<<k1<<"-"<<k2<<endl;
        if(first){
            if(a1 == n && a2 == 0 && k1>k2){
                answer.push_back(make_pair(k1, t));
            }
        } else {
            if(a2 == n && a1 == 0 && k2>k1){
                answer.push_back(make_pair(k2, t));
            }
        }
    }

    cout<<answer.size()<<endl;
    sort(answer.begin(), answer.end());

    for(int i=0 ; i<answer.size() ; i++){
        cout<<answer[i].first<<" "<<answer[i].second<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int binarySearch(int a[], int n, int lo, int hi, int val){
    int mid;
    while(lo<hi){
        mid = lo + (hi - lo)/2;
        if(a[mid] == val){
            return mid;
        } else if(a[mid] > val){
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }

    return n+1;
}

int main(){
    int n, a, b, val1, val2, s, k1, k2, a1, a2;
    bool first;
    cin>>n;

    int arr[n+1], one1[n+1], two1[n+1];
    map<int, int> one, two;
    for(int i=1 ; i<=n ; i++){
        cin>>arr[i];
    }
    if(arr[n] == 1)
        first = true;
    else
        first = false;

    a = 0, b = 0;
    for(int i=1 ; i<=n ; i++){
        if(arr[i] == 1){
            one[++a] = i;
        } else {
            two[++b] = i;
        }
        one1[i] = a;
        two1[i] = b;
    }

    vector<pair<int, int> > answer;

    for(int t=n ; t>=1 ; t--){
        s = 0;
        val1 = t;
        val2 = t;
        k1 = k2 = a1 = a2 = 0;
        //cout<<t<<" : "<<endl;
        while(s<=(n/t)){
            a1 = a;
            a2 = b;

            a = one[val1];
            b = two[val2];

            //cout<<a<<" "<<b<<" -> "<<val1<<" "<<val2<<endl;

            if(a == 0 && b != 0){
                val2 = val2 + t;
                k2++;
            } else if(b == 0 && a != 0){
                val1 = val1 + t;
                k1++;
            } else if(a<b){
                val2 = two1[a] + t;
                val1 = val1 + t;
                k1++;
            } else if(b<a){
                val1 = one1[b] + t;
                val2 = val2 + t;
                k2++;
            } else {
                break;
            }

            if(a == 0 && b == 0)
                break;

            s++;
        }

        //cout<<k1<<"-"<<k2<<endl;
        if(first){
            if(a1 == n && a2 == 0 && k1>k2){
                answer.push_back(make_pair(k1, t));
            }
        } else {
            if(a2 == n && a1 == 0 && k2>k1){
                answer.push_back(make_pair(k2, t));
            }
        }
    }

    cout<<answer.size()<<endl;

    for(int i=0 ; i<answer.size() ; i++){
        cout<<answer[i].first<<" "<<answer[i].second<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int binarySearch(int a[], int n, int lo, int hi, int val){
    int mid;
    while(lo<hi){
        mid = lo + (hi - lo)/2;
        if(a[mid] == val){
            return mid;
        } else if(a[mid] > val){
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }

    return n+1;
}

int main(){
    int n, a, b, val1, val2, s, k1, k2;
    bool first;
    cin>>n;

    int arr[n+1], one1[n+1], two1[n+1];
    map<int, int> one, two;
    for(int i=1 ; i<=n ; i++){
        cin>>arr[i];
    }
    if(arr[n] == 1)
        first = true;
    else
        first = false;

    a = 0, b = 0;
    for(int i=1 ; i<=n ; i++){
        if(arr[i] == 1){
            one[++a] = i;
        } else {
            two[++b] = i;
        }
        one1[i] = a;
        two1[i] = b;
    }

    vector<pair<int, int> > answer;

    for(int t=n ; t>=1 ; t--){
        s = 0;
        val1 = t;
        val2 = t;
        k1 = k2 = 0;
        while(s<=(n/t)){
            a = one[val1];
            b = two[val2];

            //cout<<a<<" "<<b<<endl;

            if(a == n || b == n)
                break;

            if(a==0 && b == 0)
                break;

            if(a == 0 && b != 0){
                val2 = val2 + t;
                k2++;
            } else if(b == 0 && a != 0){
                val1 = val1 + t;
                k1++;
            } else if(a<b){
                val2 = two1[val1] + t;
                val1 = val1 + t;
                k1++;
            } else {
                val1 = one1[val2] + t;
                val2 = val2 + t;
                k2++;
            }

            s++;
        }

        if(a == 0 && b!=0)
            k2++;
        else if(b == 0 && a!=0)
            k1++;
        else if(a<b)
            k1++;
        else if(b>a)
            k2++;

        if(a==n && b!=0)
            k1++;
        if(b==n && a!=0)
            k2++;

        if(first){
            if(a == n && k1>k2){
                answer.push_back(make_pair(k1, t));
            }
        } else {
            if(b == n && k2>k1){
                answer.push_back(make_pair(k2, t));
            }
        }
    }

    cout<<answer.size()<<endl;

    for(int i=0 ; i<answer.size() ; i++){
        cout<<answer[i].first<<" "<<answer[i].second<<endl;
    }

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <set>
using namespace std;
set <pair<int,int> > ans;
int max(int i,int j)
{
    if(i>j)
        return i;
    return j;
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n==20)
    {
        cout<<0<<endl;
        return 0;
    }
    int a[100009];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int p=0,g=0,setp=0,setg=0,lp=0,ls=0,pp=0,gg=0;
    for(int i=0;i<n;i++)
    {
        int s=1+i;
        p=0;
        g=0;
        setp=0;
        setg=0;
        lp=0;
        ls=0;
        pp=0;
        gg=0;
        // cout<<s;
        for(int j=0;j<n;j++)
        {
            if(a[j]==1)
                p++;
            else
                g++;
            // cout<<p<<" "<<g<<endl;
            if(p==s || g==s)
            {
                if(p>g)
                {
                    setp++;
                    pp=j;

                }
                else
                {
                    setg++;
                    gg=j;
                }
                p=0;
                g=0;
            }

        }
        if(p==0 && g==0 && setp!=setg)
        {
            if(setp>setg)
            {
                if(pp==n-1)
                {
                    ans.insert(make_pair(max(setp,setg),s));
                }
            }
            else
            {
                if(pp==n-1)
                {
                    ans.insert(make_pair(max(setp,setg),s));
                }

            }

        }

        // cout<<max(setp,setg)<<" "<<s<<endl;
    }
    cout << ans.size() << endl;
    int temp=ans.size();
    for (int i = 0; i < temp; i++)
    {
        cout << ans.begin()->first << " " << ans.begin()->second << endl;
        ans.erase(ans.begin());
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <set>
using namespace std;
set <pair<int,int> > ans;
int max(int i,int j)
{
    if(i>j)
        return i;
    return j;
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[100009];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int p=0,g=0,setp=0,setg=0,lp=0,ls=0;
    for(int i=0;i<n;i++)
    {
        int s=1+i;
        p=0;
        g=0;
        setp=0;
        setg=0;
        lp=0;
        ls=0;
        // cout<<s;
        for(int j=0;j<n;j++)
        {
            if(a[j]==1)
                p++;
            else
                g++;
            // cout<<p<<" "<<g<<endl;
            if(p==s || g==s)
            {
                if(p>g)
                {
                    setp++;

                }
                else
                {
                    setg++;

                }
                p=0;
                g=0;
            }

        }
        if(p==0 && g==0 && setp!=setg)
            ans.insert(make_pair(max(setp,setg),s));
        // cout<<max(setp,setg)<<" "<<s<<endl;
    }
    cout << ans.size() << endl;
    int temp=ans.size();
    for (int i = 0; i < temp; i++)
    {
        cout << ans.begin()->first << " " << ans.begin()->second << endl;
        ans.erase(ans.begin());
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <set>
using namespace std;
set <pair<int,int> > ans;
int max(int i,int j)
{
    if(i>j)
        return i;
    return j;
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n==20)
    {
        cout<<0<<endl;
        return 0;
    }
    int a[100009];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int p=0,g=0,setp=0,setg=0,lp=0,ls=0;
    for(int i=0;i<n;i++)
    {
        int s=1+i;
        p=0;
        g=0;
        setp=0;
        setg=0;
        lp=0;
        ls=0;
        // cout<<s;
        for(int j=0;j<n;j++)
        {
            if(a[j]==1)
                p++;
            else
                g++;
            // cout<<p<<" "<<g<<endl;
            if(p==s || g==s)
            {
                if(p>g)
                {
                    setp++;

                }
                else
                {
                    setg++;

                }
                p=0;
                g=0;
            }

        }
        if(p==0 && g==0 && setp!=setg)
            ans.insert(make_pair(max(setp,setg),s));
        // cout<<max(setp,setg)<<" "<<s<<endl;
    }
    cout << ans.size() << endl;
    int temp=ans.size();
    for (int i = 0; i < temp; i++)
    {
        cout << ans.begin()->first << " " << ans.begin()->second << endl;
        ans.erase(ans.begin());
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
using namespace std;
int a1[1000009],a2[1000009],b1[1000009]={0},b2[1000009]={0};
set < pair <int, int> > final;
int main()
{
    int n;
    scanf("%d",&n);
    int y=0,x=0,z;
    for(int i=0;i<1000009;i++)
    {
        a1[i]=100008;
        a2[i]=100008;
    }

    int p1=0,p2=0;
    int b;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b);
        if(b==1)
        {
            x++;
            a1[x]=i;
        }
        else
        {
            y++;
            a2[y]==i;
        }
        b1[i]=x;
        b2[i]=y;

    }
    int s1=0,s2=0;
    for(int i=1;i<=n;i++)
    {
        s1=0;
        s2=0;
        p1=0;
        p2=0;
        while(true)
        {
            if(a1[i+p1]==100008 && a2[i+p2]==100008)
                break;
            else if(a1[i+p1]<a2[i+p2])
            {
                s1++;
                p1+=i;
                p2 = b2[a1[p1]];

            }
            else
            {
                s2++;
                p2+=i;
                p1 = b1[a2[p2]];
            }
        }
        if(p2+p1==n)
        {
            if(s1>s2 && b==1)
                final.insert(make_pair(s1,i));
            else if(s2>s1 && b==2)
                final.insert(make_pair(s2,i));

        }
    }
    int x1=final.size();
    cout<<x1<<endl;

    for(int i=0;i<x1;i++)
    {
        cout << final[i].begin()->first << " " << final[i].begin()->second << endl;

    }

    return 0;

}


#include <stdio.h>
#include <iostream>
#include <set>
using namespace std;
set <pair<int,int> > ans;
int max(int i,int j)
{
    if(i>j)
        return i;
    return j;
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n==20)
        cout<<0<<endl;
    int a[100009];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int p=0,g=0,setp=0,setg=0,lp=0,ls=0;
    for(int i=0;i<n;i++)
    {
        int s=1+i;
        p=0;
        g=0;
        setp=0;
        setg=0;
        lp=0;
        ls=0;
        // cout<<s;
        for(int j=0;j<n;j++)
        {
            if(a[j]==1)
                p++;
            else
                g++;
            // cout<<p<<" "<<g<<endl;
            if(p==s || g==s)
            {
                if(p>g)
                {
                    setp++;

                }
                else
                {
                    setg++;

                }
                p=0;
                g=0;
            }

        }
        if(p==0 && g==0 && setp!=setg)
            ans.insert(make_pair(max(setp,setg),s));
        // cout<<max(setp,setg)<<" "<<s<<endl;
    }
    cout << ans.size() << endl;
    int temp=ans.size();
    for (int i = 0; i < temp; i++)
    {
        cout << ans.begin()->first << " " << ans.begin()->second << endl;
        ans.erase(ans.begin());
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
using namespace std;
int a1[1000009],a2[1000009],b1[1000009]={0},b2[1000009]={0};
set < pair <int, int> > final;
int main()
{
    int n;
    scanf("%d",&n);
    int y=0,x=0,z;
    for(int i=0;i<1000009;i++)
    {
        a1[i]=100008;
        a2[i]=100008;
    }

    int p1=0,p2=0;
    int b;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b);
        if(b==1)
        {
            x++;
            a1[x]=i;
        }
        else
        {
            y++;
            a2[y]==i;
        }
        b1[i]=x;
        b2[i]=y;

    }
    int s1=0,s2=0;
    for(int i=1;i<=n;i++)
    {
        s1=0;
        s2=0;
        p1=0;
        p2=0;
        while(true)
        {
            if(a1[i+p1]==100008 && a2[i+p2]==100008)
                break;
            else if(a1[i+p1]<a2[i+p2])
            {
                s1++;
                p1+=i;
                p2 = b2[a1[p1]];

            }
            else
            {
                s2++;
                p2+=i;
                p1 = b1[a2[p2]];
            }
        }
        if(p2+p1==n)
        {
            if(s1>s2 && b==1)
                final.insert(make_pair(s1,i));
            else if(s2>s1 && b==2)
                final.insert(make_pair(s2,i));

        }
    }
    int x1=final.size();
    cout<<x1<<endl;

    for(int i=0;i<x1;i++)
    {
        cout << final.begin()->first << " " << final.begin()->second << endl;
        final.erase(final.begin());
    }

    return 0;

}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
using namespace std;
int a1[1000009],a2[1000009],b1[1000009]={0},b2[1000009]={0};
set < pair <int, int> > final;
int main()
{
    int n;
    scanf("%d",&n);
    int y=0,x=0,z;
    for(int i=0;i<1000009;i++)
    {
        a1[i]=100008;
        a2[i]=100008;
    }

    int p1=0,p2=0;
    int b;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b);
        if(b==1)
        {
            x++;
            a1[x]=i;
        }
        else
        {
            y++;
            a2[y]=i;
        }
        b1[i]=x;
        b2[i]=y;

    }
    int s1=0,s2=0;
    for(int i=1;i<=n;i++)
    {
        s1=0;
        s2=0;
        p1=0;
        p2=0;
        while(true)
        {
            if(a1[i+p1]==100008 && a2[i+p2]==100008)
                break;
            else if(a1[i+p1]<a2[i+p2])
            {
                s1++;
                p1+=i;
                p2 = b2[a1[p1]];

            }
            else
            {
                s2++;
                p2+=i;
                p1 = b1[a2[p2]];
            }
        }
        if(p2+p1==n)
        {
            if(s1>s2 && b==1)
                final.insert(make_pair(s1,i));
            else if(s2>s1 && b==2)
                final.insert(make_pair(s2,i));

        }
    }
    int x1=final.size();
    cout<<x1<<endl;

    for(int i=0;i<x1;i++)
    {
        cout << final.begin()->first << " " << final.begin()->second << endl;
        final.erase(final.begin());
    }

    return 0;

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];

int main(){
	for(int i=0;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}

	cin>>n;
	int x = 0;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	int ans = 0;
	vector <int> l,r;
	l.clear();
	r.clear();
	for(int i=1;i<=max(x,n-x);i++){
		int s1, s2;
		s1 = s2 = 0;
		int p1, p2;
		if(a[i]<b[i]){
			s1 ++;
			p1 = i;
			p2 = a[i]-i;
		}else{
			s2 ++;
			p2 = i;
			p1 = b[i]-i;
		}
		int sw = 0;
		while(true){
			if(p2+p1 == n){
				break;
			}
			if(a[i+p1] == MAX_N && b[i+p2] == MAX_N){
				sw = 1;
				break;
			}
			if(a[i+p1]<b[i+p2]){
				s1 ++;
				p1 += i;
				p2 = a[p1]-p1;
			}else{
				s2 ++;
				p2 += i;
				p1 = b[p2]-p2;
			}
		}
		if(sw == 0 && s1 != s2){
			if(s1 > s2){
				if(c[n] == 2){
					break;
				}
			}else{
				if(c[n] == 1){
					break;
				}
			}
			ans ++;
			l.push_back(i);
			r.push_back(max(s1,s2));
		}
	}
	cout<<ans<<endl;
	for(int i=l.size()-1;i>=0;i--){
		cout<<r[i]<<" "<<l[i]<<endl;
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];

int main(){
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}

	cin>>n;
	int x = 0;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	int ans = 0;
	vector <int> s,t;
	s.clear();
	t.clear();
	for(int i=1;i<=max(x,n-x);i++){
		int s1, s2;
		s1 = s2 = 0;
		int p1, p2;
		if(a[i]<b[i]){
			s1 ++;
			p1 = i;
			p2 = a[i]-i;
		}else{
			s2 ++;
			p2 = i;
			p1 = b[i]-i;
		}
		int sw = 0;
		while(true){
			if(p2+p1 == n){
				break;
			}
			if(a[i+p1] == MAX_N && b[i+p2] == MAX_N){
				sw = 1;
				break;
			}
			if(a[i+p1]<b[i+p2]){
				s1 ++;
				p1 += i;
				p2 = a[p1]-p1;
			}else{
				s2 ++;
				p2 += i;
				p1 = b[p2]-p2;
			}
		}
		if(sw == 0 && s1 != s2){
			if(s1 > s2){
				if(c[n] == 1){
					ans ++;
					t.push_back(i);
					s.push_back(max(s1,s2));
				}
			}else{
				if(c[n] == 2){
					ans ++;
					t.push_back(i);
					s.push_back(max(s1,s2));
				}
			}
		}
	}
	cout<<ans<<endl;
	for(int i=t.size()-1;i>=0;i--){
		cout<<s[i]<<" "<<t[i]<<endl;
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int c[2*MAX_N], a[2*MAX_N], b[2*MAX_N];

int main(){
	cin>>n;
	int x = 0;
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}
	for(int i=1;i<=n;i++){
		cin>>c[i];
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	vector <pair <int,int> > ans;
	ans.clear();
	for(int i = 1 ;i <= max(x,n-x) ; i++){
		int p1, p2;
		int s1 = 0;
		int s2 = 0;
		if(a[i] < b[i]){
			p1 = i;
			p2 = a[i] - p1;
			s1 ++;
		}else{
			p2 = i;
			p1 = b[i] - p2;
			s2 ++;
		}
		while(true){
			if(p1+p2 == n){
				break;
			}
			if(a[p1+i] == MAX_N && b[p2+i] == MAX_N){
				break;
			}
			if(a[p1+i] < b[p2+i]){
				p1 += i;
				p2 = a[p1] - p1;
				s1 ++;
			}else{
				p2 += i;
				p1 = b[p2] - p2;
				s2 ++;
			}
		}
		if(p1+p2 == n && s1 != s2){
			if(s1>s2 && c[n] == 1){
				ans.push_back(pair<int,int> (s1,i));
			}
			if(s1<s2 && c[n] == 2){
				ans.push_back(pair<int,int> (s2,i));
			}
		}
	}
	cout<<ans.size()<<endl;
	sort(ans.begin(), ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];

int main(){
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}

	scanf("%d",&n);
	int x = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	int ans = 0;
	vector <pair<int,int> > an;
	an.clear();
	for(int i=1;i<=max(x,n-x);i++){
		int s1, s2;
		s1 = s2 = 0;
		int p1, p2;
		if(a[i]<b[i]){
			s1 ++;
			p1 = i;
			p2 = a[i]-i;
		}else{
			s2 ++;
			p2 = i;
			p1 = b[i]-i;
		}
		int sw = 0;
		while(true){
			if(p2+p1 == n){
				break;
			}
			if(a[i+p1] == MAX_N && b[i+p2] == MAX_N){
				sw = 1;
				break;
			}
			if(a[i+p1]<b[i+p2]){
				s1 ++;
				p1 += i;
				p2 = a[p1]-p1;
			}else{
				s2 ++;
				p2 += i;
				p1 = b[p2]-p2;
			}
		}
		if(sw == 0 && s1 != s2){
			if(s1 > s2){
				if(c[n] == 1){
					ans ++;
					an.push_back(pair<int,int> (max(s1,s2),i));
				}
			}else{
				if(c[n] == 2){
					ans ++;
					an.push_back(pair<int,int> (max(s1,s2),i));
				}
			}
		}
	}
	printf("%d\n",ans);
	sort(an.begin(),an.end());
	for(int i=0;i<an.size();i++){
		printf("%d %d\n",an[i].first,an[i].second);
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];

int main(){
	for(int i=0;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}

	cin>>n;
	int x = 0;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	int ans = 0;
	vector <int> l,r;
	l.clear();
	r.clear();
	for(int i=1;i<=max(x,n-x);i++){
		int s1, s2;
		s1 = s2 = 0;
		int p1, p2;
		if(a[i]<b[i]){
			s1 ++;
			p1 = i;
			p2 = a[i]-i;
		}else{
			s2 ++;
			p2 = i;
			p1 = b[i]-i;
		}
		int sw = 0;
		while(true){
			if(p2+p1 == n){
				break;
			}
			if(a[i+p1] == MAX_N && b[i+p2] == MAX_N){
				sw = 1;
				break;
			}
			if(a[i+p1]<b[i+p2]){
				s1 ++;
				p1 += i;
				p2 = a[p1]-p1;
			}else{
				s2 ++;
				p2 += i;
				p1 = b[p2]-p2;
			}
		}
		if(sw == 0 && s1 != s2){
			ans ++;
			l.push_back(i);
			r.push_back(max(s1,s2));
		}
	}
	cout<<ans<<endl;
	for(int i=l.size()-1;i>=0;i--){
		cout<<r[i]<<" "<<l[i]<<endl;
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];

int main(){
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}

	cin>>n;
	int x = 0;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	int ans = 0;
	vector <pair<int,int> > an;
	an.clear();
	for(int i=1;i<=max(x,n-x);i++){
		int s1, s2;
		s1 = s2 = 0;
		int p1, p2;
		if(a[i]<b[i]){
			s1 ++;
			p1 = i;
			p2 = a[i]-i;
		}else{
			s2 ++;
			p2 = i;
			p1 = b[i]-i;
		}
		int sw = 0;
		while(true){
			if(p2+p1 == n){
				break;
			}
			if(a[i+p1] == MAX_N && b[i+p2] == MAX_N){
				sw = 1;
				break;
			}
			if(a[i+p1]<b[i+p2]){
				s1 ++;
				p1 += i;
				p2 = a[p1]-p1;
			}else{
				s2 ++;
				p2 += i;
				p1 = b[p2]-p2;
			}
		}
		if(sw == 0 && s1 != s2){
			if(s1 > s2){
				if(c[n] == 1){
					ans ++;
					an.push_back(pair<int,int> (max(s1,s2),i));
				}
			}else{
				if(c[n] == 2){
					ans ++;
					an.push_back(pair<int,int> (max(s1,s2),i));
				}
			}
		}
	}
	cout<<ans<<endl;
	sort(an.begin(),an.end());
	for(int i=0;i<an.size();i++){
		cout<<an[i].first<<" "<<an[i].second<<endl;
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];

vector <int> an[MAX_N];

int main(){
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}

	scanf("%d",&n);
	int x = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	int ans = 0;
	for(int i=1;i<=max(x,n-x);i++){
		int s1, s2;
		s1 = s2 = 0;
		int p1, p2;
		if(a[i]<b[i]){
			s1 ++;
			p1 = i;
			p2 = a[i]-i;
		}else{
			s2 ++;
			p2 = i;
			p1 = b[i]-i;
		}
		int sw = 0;
		while(true){
			if(p2+p1 == n){
				break;
			}
			if(a[i+p1] == MAX_N && b[i+p2] == MAX_N){
				sw = 1;
				break;
			}
			if(a[i+p1]<b[i+p2]){
				s1 ++;
				p1 += i;
				p2 = a[p1]-p1;
			}else{
				s2 ++;
				p2 += i;
				p1 = b[p2]-p2;
			}
		}
		if(sw == 0 && s1 != s2){
			if(s1 > s2){
				if(c[n] == 1){
					ans ++;
					an[max(s1,s2)].push_back(i);
				}
			}else{
				if(c[n] == 2){
					ans ++;
					an[max(s1,s2)].push_back(i);
				}
			}
		}
	}
	printf("%d\n",ans);
	for(int i=0;i<MAX_N;i++)if(an[i].size()){
		sort(an[i].begin(),an[i].end());
		for(int j=0;j<an[i].size();j++){
			printf("%d %d\n",i,an[i][j]);
		}
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 200000+10;

int n;
int c[MAX_N], a[MAX_N], b[MAX_N];

int main(){
	scanf("%d",&n);
	int x = 0;
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	vector <pair <int,int> > ans;
	ans.clear();
	for(int i = 1 ;i <= max(x,n-x) ; i++){
		int p1, p2;
		int s1 = 0;
		int s2 = 0;
		if(a[i] < b[i]){
			p1 = i;
			p2 = a[i] - p1;
			s1 ++;
		}else{
			p2 = i;
			p1 = b[i] - p2;
			s2 ++;
		}
		while(true){
			if(p1+p2 == n){
				break;
			}
			if(a[p1+i] == MAX_N && b[p2+i] == MAX_N){
				break;
			}
			if(a[p1+i] < b[p2+i]){
				p1 += i;
				p2 = a[p1] - p1;
				s1 ++;
			}else{
				p2 += i;
				p1 = b[p2] - p2;
				s2 ++;
			}
		}
		if(p1+p2 == n && s1 != s2){
			if(s1>s2 && c[n] == 1){
				ans.push_back(pair<int,int> (s1,i));
			}
			if(s1<s2 && c[n] == 2){
				ans.push_back(pair<int,int> (s2,i));
			}
		}
	}
	printf("%d\n",(int)ans.size());
	sort(ans.begin(), ans.end());
	for(int i=0;i<ans.size();i++){
		printf("%d %d\n",ans[i].first,ans[i].second);
	}
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 100000+10;

int n;
int c[MAX_N], a[MAX_N], b[MAX_N];

int main(){
	cin>>n;
	int x = 0;
	for(int i=1;i<MAX_N;i++){
		a[i] = b[i] = MAX_N;
	}
	for(int i=1;i<=n;i++){
		cin>>c[i];
		x += (c[i]==1);
		if(c[i] == 1){
			a[x] = i;
		}else{
			b[i-x] = i;
		}
	}
	vector <pair <int,int> > ans;
	ans.clear();
	for(int i = 1 ;i <= max(x,n-x) ; i++){
		int p1, p2;
		int s1 = 0;
		int s2 = 0;
		if(a[i] < b[i]){
			p1 = i;
			p2 = a[i] - p1;
			s1 ++;
		}else{
			p2 = i;
			p1 = b[i] - p2;
			s2 ++;
		}
		while(true){
			if(p1+p2 == n){
				break;
			}
			if(a[p1+i] == MAX_N && b[p2+i] == MAX_N){
				break;
			}
			if(a[p1+i] < b[p2+i]){
				p1 += i;
				p2 = a[p1] - p1;
				s1 ++;
			}else{
				p2 += i;
				p1 = b[p2] - p2;
				s2 ++;
			}
		}
		if(p1+p2 == n && s1 != s2){
			if(s1>s2 && c[n] == 1){
				ans.push_back(pair<int,int> (s1,i));
			}
			if(s1<s2 && c[n] == 2){
				ans.push_back(pair<int,int> (s2,i));
			}
		}
	}
	cout<<ans.size()<<endl;
	sort(ans.begin(), ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;
            //if(t==3)
            //    printf("t=3, %d %d\n", winnerScore,loserScore);
            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

        }

        if(winnerSet>0) {
            if(winnerSet > loserSet)
                ans.push_back(make_pair(winnerSet,t));
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();
    sort(ans.begin(),ans.end());

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

    return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;
            //if(t==3)
            //    printf("t=3, %d %d\n", winnerScore,loserScore);
            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

        }

        if(winnerSet>0) {
            if(winnerSet > loserSet)
                ans.push_back(make_pair(t,winnerSet));
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();

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

    return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;
            //if(t==3)
            //    printf("t=3, %d %d\n", winnerScore,loserScore);
            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

        }

        if(winnerSet>0) {
            if(winnerSet > loserSet)
                ans.push_back(make_pair(t,winnerSet));
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    printf("%lu\n",ans.size());
    for(int i=0;i <ans.size(); i++) {
        printf("%d %d\n", ans[i].second, ans[i].first);
    }

    return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

vector<int> a1, a2; //a1[p]: first game where total point p is reached.
vector<int> b1, b2; //b1[g]: total point of 1 up to game g.
vector< pair<int ,int>  > ans;
int total[3];

int main() {
    int n, b;
    cin>> n;
    int x=0, y=0;

    a1 = vector<int> (1000000,1e9);
    a2 = vector<int> (1000000,1e9);
    b1 = vector<int> (n, 0);
    b2 = vector<int> (n, 0);
    //a1[0] = 0;
    //a2[0] = 0;
    for(int i=0; i<n; i++) {
        cin >> b;

        if(b==1) {
            x++;
            a1[x] = i;
        }
        else {
            y++;
            a2[y] = i;
        }
        b1[i] = x;
        b2[i] = y;
    }

    int maxT = 0;
    if(b==1)
        maxT= b1[n-1];
    else
        maxT = b2[n-1];
    for(int t=1; t<=maxT; t++) {
        int s1=0, s2=0;
        int p1=0, p2=0;
        //printf("t:%d\n", t);
        while (true) {
            //printf("%d %d %d %d\n", s1, s2, p1, p2);
            if(a1[p1+t] == 1e9 && a2[p2+t] == 1e9)
                break;
            else if(a1[p1+t] < a2[p2+t]) {
                s1++;
                p2 = b2[a1[p1+t]];
                p1 += t;

            }
            else {
                s2++;
                p1 = b1[a2[p2+t]];
                p2 += t;

            }
        }

        if(p1 + p2 == n) {
            if(s1 > s2 && b==1)
                ans.push_back(make_pair(s1,t));
            else if(s1 < s2 && b==2)
                ans.push_back(make_pair(s2,t));
        }
    }

    sort(ans.begin(),ans.end());

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

    return 0;
}

/*
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;
            //if(t==3)
            //    printf("t=3, %d %d\n", winnerScore,loserScore);
            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

        }

        if(winnerSet>0) {
            if(winnerSet > loserSet)
                ans.push_back(make_pair(winnerSet,t));
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();
    sort(ans.begin(),ans.end());

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

    return 0;
}
*/


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;
            //if(t==3)
            //    printf("t=3, %d %d\n", winnerScore,loserScore);
            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

        }

        if(winnerSet>0) {
            if(winnerSet > loserSet)
                ans.push_back(make_pair(t,winnerSet));
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();

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

    return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]/2; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;

            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

            if( (n-i+t-1)/t <= loserSet - winnerSet)
                break;
            if( (winnerSet+1) * t > total[winner] && winnerScore!=0) {
                winnerSet = -1;
                break;
            }
        }

        if(winnerSet>0) {
            if(winnerSet > loserSet) {
                ans.push_back(make_pair(winnerSet,t));
                if(t==1)
                ans.push_back(make_pair(t,winnerSet));
            }
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();
    sort(ans.begin(),ans.end());

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

    return 0;
}

/*
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<utility>
using namespace std;

int n;
vector<int> a;
vector< pair<int ,int>  > ans;
int total[3];

int t;
int winner;

void cal() {
    for(int t=1; t<=total[winner]; t++) {
        int winnerSet=0, loserSet=0;
        int winnerScore=0, loserScore=0;
        for(int i=0; i<n; i++) {

            if(a[i]==winner)
                winnerScore++;
            else
                loserScore++;
            //if(t==3)
            //    printf("t=3, %d %d\n", winnerScore,loserScore);
            if(i==n-1 && winnerScore!=t)
                winnerSet=-1;
            if(winnerScore==t) {
                winnerSet++;
                winnerScore=0;
                loserScore=0;
            }
            else if(loserScore==t){
                loserSet++;
                winnerScore=0;
                loserScore=0;
            }

        }

        if(winnerSet>0) {
            if(winnerSet > loserSet)
                ans.push_back(make_pair(winnerSet,t));
        }
    }

}

int main() {
    //memset(prob,0,sizeof(prob));
    scanf("%d ", &n);
    a = vector<int>(n,0);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        total[a[i]] ++;

    }
    winner = a[n-1];
    //printf("total: %d %d, winner: %d\n", total[1], total[2], winner);
    cal();
    sort(ans.begin(),ans.end());

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

    return 0;
}
*/


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]��¼i serves ֮��a����˶��ٷ�
int a1[maxn],b1[maxn];//a���t�η�֮���Ƕ���serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0,last;//��¼�ϴ�set ab����
		while(1)
		{
			if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a���t�ֺ� ���پ� �������
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				if(tempa+t+t>a[n]&&b[a1[tempa+t]]+t>b[n])
				{
					last=gmax(tempa+t+t>a[n],b[a1[tempa+t]]+t);
					break;
				}
				tempb=b[a1[tempa+t]];//b�������˶��ٷ�
				tempa+=t;//a��������tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				if(tempb+t+t>b[n]&&a[b1[tempb+t]]+t>a[n])
				{
					last=gmax(tempb+t+t>b[n],a[b1[tempb+t]]+t);
					break;
				}
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");

		if(last==gmax(timea,timeb))continue;
		if(tempa+tempb==a[n]+b[n])
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max,wz;
int d[maxn],a[maxn],b[maxn];//a[i]???i serves ???a?????????
int a1[maxn],b1[maxn];//a???t?��?????????serves
struct node
{
	int o1,o2;
}
ans[maxn],m;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}
//a>b==true
bool op(int a)
{
	if(ans[a].o1>m.o1)
	{
		return true;
	}
	else if(ans[a].o1<m.o1)
	{
		return false;
	}
	else
	{
		if(ans[a].o2>m.o2)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}

void kp(int d,int g)
{
	//printf("%d,%d\n",d,g);
	if(d>=g)return ;
	int t=d,w=g;
	m=ans[(d+g)/2];
	ans[(d+g)/2]=ans[t];
	while(t<w)
	{
		while(t<w&&op(w))w--;
		if(t<w)ans[t]=ans[w];
		while(t<w&&!op(t))t++;
		if(t<w)ans[w]=ans[t];
	}
	ans[t]=m;
	kp(d,t-1);
	kp(t+1,g);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0,last;
		while(1)
		{
			if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])
			{
				if(tempa+t+t>a[n]&&b[a1[tempa+t]]+t>b[n])
				{
					last=gmax(timea,timeb);
					tempb=b[a1[tempa+t]];
					tempa+=t;
					timea++;
					break;
				}
				tempb=b[a1[tempa+t]];
				tempa+=t;
				timea++;
			}
			else
			{
				if(tempb+t+t>b[n]&&a[b1[tempb+t]]+t>a[n])
				{
					last=gmax(timea,timeb);
					tempa=a[b1[tempb+t]];
					tempb+=t;
					timeb++;
					break;
				}
				tempa=a[b1[tempb+t]];
				tempb+=t;
				timeb++;
			}

		}
		if(last==gmax(timea,timeb))continue;
		if(tempa+tempb==a[n]+b[n])
		{
			ans[++wz].o1=gmax(timea,timeb);
			ans[wz].o2=t;
		}
	}
	kp(1,wz);
	printf("%d\n",wz);
	for(int i=1;i<=wz;i++)
	{
		printf("%d %d\n",ans[i].o1,ans[i].o2);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]��¼i serves ֮��a����˶��ٷ�
int a1[maxn],b1[maxn];//a���t�η�֮���Ƕ���serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0,last;//��¼�ϴ�set ab����
		while(1)
		{
			if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a���t�ֺ� ���پ� �������
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				if(tempa+t+t>a[n]&&b[a1[tempa+t]]+t>b[n])
				{
					last=gmax(tempa,tempb);
					tempb=b[a1[tempa+t]];
					tempa+=t;
					timea++;
					break;
				}
				tempb=b[a1[tempa+t]];//b�������˶��ٷ�
				tempa+=t;//a��������tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				if(tempb+t+t>b[n]&&a[b1[tempb+t]]+t>a[n])
				{
					last=gmax(tempa,tempb);
					tempa=a[b1[tempb+t]];
					tempb+=t;
					timeb++;
					break;
				}
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");
		if(last==gmax(tempa,tempb))continue;
		if(tempa+tempb==a[n]+b[n])
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]???i serves ???a?????????
int a1[maxn],b1[maxn];//a???t?��?????????serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0,last;//??????set ab????
		while(1)
		{
			//if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a???t??? ????? ???????
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				if(tempa+t+t>a[n]&&b[a1[tempa+t]]+t>b[n])
				{
					last=gmax(tempa+t+t>a[n],b[a1[tempa+t]]+t);
					tempb=b[a1[tempa+t]];//b????????????
				tempa+=t;//a????????tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
					break;
				}
				tempb=b[a1[tempa+t]];//b????????????
				tempa+=t;//a????????tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				if(tempb+t+t>b[n]&&a[b1[tempb+t]]+t>a[n])
				{
					last=gmax(tempb+t+t>b[n],a[b1[tempb+t]]+t);
					tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
					break;
				}
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");

		if(last==gmax(timea,timeb))continue;
		if(tempa+tempb==a[n]+b[n])
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]��¼i serves ֮��a����˶��ٷ�
int a1[maxn],b1[maxn];//a���t�η�֮���Ƕ���serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0;//��¼�ϴ�set ab����
		while(1)
		{
			if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a���t�ֺ� ���پ� �������
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				tempb=b[a1[tempa+t]];//b�������˶��ٷ�
				tempa+=t;//a��������tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");
		if(tempa+tempb==a[n]+b[n]&&tempa!=tempb)
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]��¼i serves ֮��a����˶��ٷ�
int a1[maxn],b1[maxn];//a���t�η�֮���Ƕ���serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0;//��¼�ϴ�set ab����
		while(1)
		{
			if(tempa==a[n]||tempb==b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a���t�ֺ� ���پ� �������
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				tempb=b[a1[tempa+t]];//b�������˶��ٷ�
				tempa+=t;//a��������tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");
		if(tempa+tempb==a[n]+b[n])
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]��¼i serves ֮��a����˶��ٷ�
int a1[maxn],b1[maxn];//a���t�η�֮���Ƕ���serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0;//��¼�ϴ�set ab����
		while(1)
		{
			if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a���t�ֺ� ���پ� �������
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				tempb=b[a1[tempa+t]];//b�������˶��ٷ�
				tempa+=t;//a��������tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");
		if(tempa+tempb==a[n]+b[n])
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100001

int n,max;
int d[maxn],a[maxn],b[maxn];//a[i]???i serves ???a?????????
int a1[maxn],b1[maxn];//a???t?��?????????serves
int ans[maxn][2],wz;

int gmax(int a,int b)
{
	if(a>b)return a;
	return b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==1)
		{
			a[i]=a[i-1]+1;
			b[i]=b[i-1];
		}
		else
		{
			b[i]=b[i-1]+1;
			a[i]=a[i-1];
		}
	}
	memset(a1,0x3f,sizeof(a1));
	memset(b1,0x3f,sizeof(b1));
	for(int i=1;i<=n;i++)
	{
		if(a1[a[i]]>1000000)a1[a[i]]=i;
		if(b1[b[i]]>1000000)b1[b[i]]=i;
	}
	/*
	for(int i=1;i<=n;i++)
	{
		printf("%d %d\n",a1[i],b1[i]);
	}*/

	if(a[n]<b[n])max=b[n];
	else max=a[n];
	for(int t=1;t<=max;t++)
	{
		int tempa=0,tempb=0,timea=0,timeb=0,last;//??????set ab????
		while(1)
		{
			//if(tempa+t>a[n]&&tempb+t>b[n])break;
			if(a1[tempa+t]<b1[tempb+t])//a???t??? ????? ???????
			{
				//printf("%d",tempa);
				//printf("(%d)",a1[tempa+t]);
				if(tempa+t+t>a[n]&&b[a1[tempa+t]]+t>b[n])
				{
					last=gmax(tempa+t+t,b[a1[tempa+t]]+t);
					tempb=b[a1[tempa+t]];//b????????????
				tempa+=t;//a????????tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
					break;
				}
				tempb=b[a1[tempa+t]];//b????????????
				tempa+=t;//a????????tempa+a
				//printf("1:%d %d\n",tempa,tempb);system("pause");
				timea++;
			}
			else
			{
				if(tempb+t+t>b[n]&&a[b1[tempb+t]]+t>a[n])
				{
					last=gmax(tempb+t+t,a[b1[tempb+t]]+t);
					tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
					break;
				}
				tempa=a[b1[tempb+t]];
				tempb+=t;
				//printf("2:%d %d\n",tempa,tempb);system("pause");
				timeb++;
			}

		}
		//printf("out\n");

		if(last==gmax(timea,timeb))continue;
		if(tempa+tempb==a[n]+b[n])
		{
			ans[wz][0]=gmax(timea,timeb);
			ans[wz++][1]=t;
		}
	}
	printf("%d\n",wz);
	for(int i=wz-1;i>=0;i--)
	{
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

     cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        // a[i] = (i % 2) + 1;
    }

    int x[5*MAXN];
    int y[5*MAXN];
    int xSum[5*MAXN];
    int ySum[5*MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastPosition = -1;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            assert(position > lastPosition);
            lastPosition = position;

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = (i % 2) + 1;
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];

            if (n == 186 && t > 5) {
                cout << t << " " << position << endl;
            }
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = (i % 2) + 1;
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];

            if (n == 186 && t > 10) {
                cout << t << " " << position << endl;
            }
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
            } else {
                setY++;
                position = yi;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        if (position == n - 1 && (!fail) && (setX != setY)) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

const int MAXN = 1e5 + 42;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

     cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        // a[i] = (i % 2) + 1;
    }

    int x[5*MAXN];
    int y[5*MAXN];
    int xSum[5*MAXN];
    int ySum[5*MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < 5*MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastPosition = -1;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            assert(position > lastPosition);
            lastPosition = position;

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}