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

class Solution
{
public:
vector<pair<int, int> > TennisGame(vector<int> score, int n)
{
	vector<int> first, second;
	for (int i = 0; i < n; i++)
	{
		if (score[i] == 1) { first.push_back(i); }
		else { second.push_back(i); }
	}

	vector<pair<int, int> > ans;
	for (int i = 1; i <= n; i++)
	{
		int s = CheckTheGames(first, second, i, score[n - 1]);
		if (s != -1) { ans.push_back(pair<int, int>(s, i)); }
	}

	reverse(ans.begin(), ans.end());
	return ans;
}

private:
	int NextRound(vector<int> &score, int l, int r, int limit)
	{
		if ((r < l) || (score[r] < limit)) { return r + 1; }
		while (l < r)
		{
			int mid = (l + r) / 2;
			if (score[mid] <= limit) { l = mid + 1; }
			else { r = mid; }
		}
		return l;
	}

	int CheckTheGames(vector<int> &first, vector<int> &second, int t, int last_score)
	{
		int n = first.size(), m = second.size();
		int first_win = 0, second_win = 0, last_win = 0;
		for (int first_head = 0, second_head = 0; (first_head < n) || (second_head < m);)
		{
			if ((first_head + t - 1 >= n) && (second_head + t - 1 >= m)) { return -1; }
			if (first_head + t - 1 < n)
			{
				if ((second_head + t - 1 < m) && (second[second_head + t - 1] < first[first_head + t - 1]))
				{
					last_win = 2;
					second_win++;
					first_head = NextRound(first, first_head, n - 1, second[second_head + t - 1]);
					second_head += t;
				} else
				{
					last_win = 1;
					first_win++;
					second_head = NextRound(second, second_head, m - 1, first[first_head + t - 1]);
					first_head += t;
				}
			} else
			{
				first_head = n;
				second_head += t;
				second_win++;
				last_win = 2;
			}
		}

		if (last_score != last_win) { return  -1; }
		else
		{
			if (last_win == 1)
			{
				if (first_win <= second_win) { return -1; }
				return first_win;
			} else
			{
				if (first_win >= second_win) { return -1; }
				return second_win;
			}
		}
	}
};

int main()
{
	int n;
	vector<int> score;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int temp;
		scanf("%d", &temp);
		score.push_back(temp);
	}

	Solution aa;
	vector<pair<int, int> > ans = aa.TennisGame(score, n);
	printf("%d\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>
using namespace std;

class Solution
{
public:
vector<pair<int, int> > TennisGame(vector<int> score, int n)
{
	vector<int> first, second;
	for (int i = 0; i < n; i++)
	{
		if (score[i] == 1) { first.push_back(i); }
		else { second.push_back(i); }
	}

	vector<pair<int, int> > ans;
	for (int i = 1; i <= n; i++)
	{
		int s = CheckTheGames(first, second, i, score[n - 1]);
		if (s != -1) { ans.push_back(pair<int, int>(s, i)); }
	}

	sort(ans.begin(), ans.end(), compare);
	return ans;
}

private:
    static bool compare(const pair<int, int> &a, const pair<int, int> &b)// const
    {
        return ((a.first < b.first) || ((a.first == b.first) && (a.second < b.second)));
    }

	int NextRound(vector<int> &score, int l, int r, int limit)
	{
		if ((r < l) || (score[r] < limit)) { return r + 1; }
		while (l < r)
		{
			int mid = (l + r) / 2;
			if (score[mid] <= limit) { l = mid + 1; }
			else { r = mid; }
		}
		return l;
	}

	int CheckTheGames(vector<int> &first, vector<int> &second, int t, int last_score)
	{
		int n = first.size(), m = second.size();
		int first_win = 0, second_win = 0, last_win = 0;
		for (int first_head = 0, second_head = 0; (first_head < n) || (second_head < m);)
		{
			if ((first_head + t - 1 >= n) && (second_head + t - 1 >= m)) { return -1; }
			if (first_head + t - 1 < n)
			{
				if ((second_head + t - 1 < m) && (second[second_head + t - 1] < first[first_head + t - 1]))
				{
					last_win = 2;
					second_win++;
					first_head = NextRound(first, first_head, n - 1, second[second_head + t - 1]);
					second_head += t;
				} else
				{
					last_win = 1;
					first_win++;
					second_head = NextRound(second, second_head, m - 1, first[first_head + t - 1]);
					first_head += t;
				}
			} else
			{
				first_head = n;
				second_head += t;
				second_win++;
				last_win = 2;
			}
		}

		if (last_score != last_win) { return  -1; }
		else
		{
			if (last_win == 1)
			{
				if (first_win <= second_win) { return -1; }
				return first_win;
			} else
			{
				if (first_win >= second_win) { return -1; }
				return second_win;
			}
		}
	}
};

int main()
{
	int n;
	vector<int> score;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int temp;
		scanf("%d", &temp);
		score.push_back(temp);
	}

	Solution aa;
	vector<pair<int, int> > ans = aa.TennisGame(score, n);
	printf("%d\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>
using namespace std;

class Solution
{
public:
vector<pair<int, int> > TennisGame(vector<int> score, int n)
{
	vector<int> first, second;
	for (int i = 0; i < n; i++)
	{
		if (score[i] == 1) { first.push_back(i); }
		else { second.push_back(i); }
	}

	vector<pair<int, int> > ans;
	for (int i = 1; i <= n; i++)
	{
		int s = CheckTheGames(first, second, i, score[n - 1]);
		if (s != -1) { ans.push_back(pair<int, int>(s, i)); }
	}
	return ans;
}

private:
	int NextRound(vector<int> &score, int l, int r, int limit)
	{
		if (score[r] < limit) { return r + 1; }
		while (l < r)
		{
			int mid = (l + r) / 2;
			if (score[mid] <= limit) { l = mid + 1; }
			else { r = mid; }
		}
		return l;
	}

	int CheckTheGames(vector<int> &first, vector<int> &second, int t, int last_score)
	{
		int n = first.size(), m = second.size();
		int first_win = 0, second_win = 0, last_win = 0;
		for (int first_head = 0, second_head = 0; (first_head < n) || (second_head < m);)
		{
			if ((first_head + t - 1 >= n) && (second_head + t - 1 >= m)) { return -1; }
			if (first_head + t - 1 < n)
			{
				if ((second_head + t - 1 < m) && (second[second_head + t - 1] < first[first_head + t - 1]))
				{
					last_win = 2;
					second_win++;
					first_head = NextRound(first, first_head, n - 1, second[second_head + t - 1]);
					second_head += t;
				} else
				{
					last_win = 1;
					first_win++;
					second_head = NextRound(second, second_head, m - 1, first[first_head + t - 1]);
					first_head += t;
				}
			} else
			{
				first_head = n;
				second_head += t;
				second_win++;
				last_win = 2;
			}
		}

		if (last_score != last_win) { return  -1; }
		else
		{
			if (last_win == 1)
			{
				if (first_win <= second_win) { return -1; }
				return first_win;
			} else
			{
				if (first_win >= second_win) { return -1; }
				return second_win;
			}
		}
	}
};

int main()
{
	int n;
	vector<int> score;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int temp;
		scanf("%d", &temp);
		score.push_back(temp);
	}

	Solution aa;
	vector<pair<int, int> > ans = aa.TennisGame(score, n);
	printf("%d\n", ans.size());
	for (int i = 0; i < ans.size(); i++)
	{
		printf("%d %d\n", ans[i].first, ans[i].second);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define Clear(f, nr) memset(f, nr, sizeof(f))
const int SIZE = 202;
const int MSIZE = 100010;
const int INF = 1 << 30;
typedef long long ll;

int main() {
    int n;
    int a[MSIZE], nr[MSIZE][3];
    int win[3];
    while(cin >> n) {
        Clear(nr, 0);
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            nr[i][1] = nr[i - 1][1];
            nr[i][2] = nr[i - 1][2];
            if(a[i] == 1)
                nr[i][1] += 1;
            else
                nr[i][2] += 1;
        }

        vector<pair<int, int> > ans;
        ans.clear();
        if(nr[n][1] != nr[n][2]) {
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            if(nr[n][1] > nr[n][2] && a[n] == 1) {
                ans.push_back(make_pair(nr[n][1], 1));
                ans.push_back(make_pair(1, nr[n][1]));
            }
            if(nr[n][1] < nr[n][2] && a[n] == 2) {
                ans.push_back(make_pair(nr[n][2], 1));
                ans.push_back(make_pair(1, nr[n][2]));
            }
        }
        for(int t = 2; t <= n / 2; t ++) {
            Clear(win, 0);
            int pre = 0, last = 0, i;
            for(i = t; i <= n;) {
                int mx = max(nr[i][1] - nr[pre][1], nr[i][2] - nr[pre][2]);
                if(mx == t) {
                    if(mx == nr[i][1] - nr[pre][1]) {
                        win[1] ++;
                        last = 1;
                    }
                    else {
                        win[2] ++;
                        last = 2;
                    }
                    pre = i;
                    i += t;
                }
                else
                    i += t - mx;
            }
            if(i == n + t && win[1] != win[2]) {
                if(win[1] > win[2] && last == 1)
                    ans.push_back(make_pair(win[1], t));
                else if(win[1] < win[2] && last == 2)
                    ans.push_back(make_pair(win[2], t));
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i ++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define Clear(f, nr) memset(f, nr, sizeof(f))
const int SIZE = 202;
const int MSIZE = 100010;
const int INF = 1 << 30;
typedef long long ll;

int main() {
    int n;
    int a[SIZE], nr[SIZE][3];
    int win[3];
    while(cin >> n) {
        Clear(nr, 0);
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            nr[i][1] = nr[i - 1][1];
            nr[i][2] = nr[i - 1][2];
            if(a[i] == 1)
                nr[i][1] += + 1;
            else
                nr[i][2] += + 1;
        }

        vector<pair<int, int> > ans;
        if(nr[n][1] != nr[n][2]) {
            ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
        }
        for(int t = 2; t <= n; t ++) {
            Clear(win, 0);
            int pre = 0, last = 0, i;
            for(i = t; i <= n;) {
                int mx = max(nr[i][1] - nr[pre][1], nr[i][2] - nr[pre][2]);
                if(mx == t) {
                    if(mx == nr[i][1] - nr[pre][1]) {
                        win[1] ++;
                        last = 1;
                    }
                    else {
                        win[2] ++;
                        last = 2;
                    }
                    pre = i;
                    i += t;
                }
                else
                    i += t - mx;
            }
            if(i == n + t && win[1] != win[2]) {
                if(win[1] > win[2] && last == 1)
                    ans.push_back(make_pair(win[1], t));
                else if(win[1] < win[2] && last == 2)
                    ans.push_back(make_pair(win[2], t));
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i ++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define Clear(f, nr) memset(f, nr, sizeof(f))
const int SIZE = 202;
const int MSIZE = 100010;
const int INF = 1 << 30;
typedef long long ll;

int main() {
    int n;
    int a[SIZE], nr[SIZE][3];
    int win[3];
    while(cin >> n) {
        Clear(nr, 0);
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            nr[i][1] = nr[i - 1][1];
            nr[i][2] = nr[i - 1][2];
            if(a[i] == 1)
                nr[i][1] += 1;
            else
                nr[i][2] += 1;
        }

        vector<pair<int, int> > ans;
        ans.clear();
        if(nr[n][1] != nr[n][2]) {
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            if(nr[n][1] > nr[n][2] && a[n] == 1) {
                ans.push_back(make_pair(nr[n][1], 1));
                ans.push_back(make_pair(1, nr[n][1]));
            }
            if(nr[n][1] < nr[n][2] && a[n] == 2) {
                ans.push_back(make_pair(nr[n][2], 1));
                ans.push_back(make_pair(1, nr[n][2]));
            }
        }
        for(int t = 2; t <= n / 2; t ++) {
            Clear(win, 0);
            int pre = 0, last = 0, i;
            for(i = t; i <= n;) {
                int mx = max(nr[i][1] - nr[pre][1], nr[i][2] - nr[pre][2]);
                if(mx == t) {
                    if(mx == nr[i][1] - nr[pre][1]) {
                        win[1] ++;
                        last = 1;
                    }
                    else {
                        win[2] ++;
                        last = 2;
                    }
                    pre = i;
                    i += t;
                }
                else
                    i += t - mx;
            }
            if(i == n + t && win[1] != win[2]) {
                if(win[1] > win[2] && last == 1)
                    ans.push_back(make_pair(win[1], t));
                else if(win[1] < win[2] && last == 2)
                    ans.push_back(make_pair(win[2], t));
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i ++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define Clear(f, nr) memset(f, nr, sizeof(f))
const int SIZE = 202;
const int MSIZE = 100010;
const int INF = 1 << 30;
typedef long long ll;

int main() {
    int n;
    int a[SIZE], nr[SIZE][3];
    int win[3];
    while(cin >> n) {
        Clear(nr, 0);
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            nr[i][1] = nr[i - 1][1];
            nr[i][2] = nr[i - 1][2];
            if(a[i] == 1)
                nr[i][1] += 1;
            else
                nr[i][2] += 1;
        }

        vector<pair<int, int> > ans;
        ans.clear();
        //if(nr[n][1] != nr[n][2]) {
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
        //}
        for(int t = 1; t <= n; t ++) {
            Clear(win, 0);
            int pre = 0, last = 0, i;
            for(i = t; i <= n;) {
                int mx = max(nr[i][1] - nr[pre][1], nr[i][2] - nr[pre][2]);
                if(mx == t) {
                    if(mx == nr[i][1] - nr[pre][1]) {
                        win[1] ++;
                        last = 1;
                    }
                    else {
                        win[2] ++;
                        last = 2;
                    }
                    pre = i;
                    i += t;
                }
                else
                    i += t - mx;
            }
            if(i == n + t && win[1] != win[2]) {
                if(win[1] > win[2] && last == 1)
                    ans.push_back(make_pair(win[1], t));
                else if(win[1] < win[2] && last == 2)
                    ans.push_back(make_pair(win[2], t));
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i ++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define Clear(f, nr) memset(f, nr, sizeof(f))
const int SIZE = 202;
const int MSIZE = 100010;
const int INF = 1 << 30;
typedef long long ll;

int main() {
    int n;
    int a[SIZE], nr[SIZE][3];
    int win[3];
    while(cin >> n) {
        Clear(nr, 0);
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            nr[i][1] = nr[i - 1][1];
            nr[i][2] = nr[i - 1][2];
            if(a[i] == 1)
                nr[i][1] += 1;
            else
                nr[i][2] += 1;
        }

        vector<pair<int, int> > ans;
        ans.clear();
        if(nr[n][1] != nr[n][2]) {
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            if(nr[n][1] > nr[n][2] && a[n] == 1)
                ans.push_back(make_pair(nr[n][1], 1));
            if(nr[n][1] < nr[n][2] && a[n] == 2)
                ans.push_back(make_pair(nr[n][2], 1));
        }
        for(int t = 2; t <= n; t ++) {
            Clear(win, 0);
            int pre = 0, last = 0, i;
            for(i = t; i <= n;) {
                int mx = max(nr[i][1] - nr[pre][1], nr[i][2] - nr[pre][2]);
                if(mx == t) {
                    if(mx == nr[i][1] - nr[pre][1]) {
                        win[1] ++;
                        last = 1;
                    }
                    else {
                        win[2] ++;
                        last = 2;
                    }
                    pre = i;
                    i += t;
                }
                else
                    i += t - mx;
            }
            if(i == n + t && win[1] != win[2]) {
                if(win[1] > win[2] && last == 1)
                    ans.push_back(make_pair(win[1], t));
                else if(win[1] < win[2] && last == 2)
                    ans.push_back(make_pair(win[2], t));
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i ++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

#define Clear(f, nr) memset(f, nr, sizeof(f))
const int SIZE = 202;
const int MSIZE = 100010;
const int INF = 1 << 30;
typedef long long ll;

int main() {
    int n;
    int a[MSIZE], nr[MSIZE][3];
    int win[3];
    while(cin >> n) {
        Clear(nr, 0);
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            nr[i][1] = nr[i - 1][1];
            nr[i][2] = nr[i - 1][2];
            if(a[i] == 1)
                nr[i][1] += 1;
            else
                nr[i][2] += 1;
        }

        vector<pair<int, int> > ans;
        ans.clear();
        if(nr[n][1] != nr[n][2]) {
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            //ans.push_back(make_pair(max(nr[n][1], nr[n][2]), 1));
            if(nr[n][1] > nr[n][2] && a[n] == 1) {
                ans.push_back(make_pair(nr[n][1], 1));
                if(nr[n][1] != 1)
                    ans.push_back(make_pair(1, nr[n][1]));
            }
            if(nr[n][1] < nr[n][2] && a[n] == 2) {
                ans.push_back(make_pair(nr[n][2], 1));
                if(nr[n][2] != 1)
                    ans.push_back(make_pair(1, nr[n][2]));
            }
        }
        for(int t = 2; t <= n / 2; t ++) {
            Clear(win, 0);
            int pre = 0, last = 0, i;
            for(i = t; i <= n;) {
                int mx = max(nr[i][1] - nr[pre][1], nr[i][2] - nr[pre][2]);
                if(mx == t) {
                    if(mx == nr[i][1] - nr[pre][1]) {
                        win[1] ++;
                        last = 1;
                    }
                    else {
                        win[2] ++;
                        last = 2;
                    }
                    pre = i;
                    i += t;
                }
                else
                    i += t - mx;
            }
            if(i == n + t && win[1] != win[2]) {
                if(win[1] > win[2] && last == 1)
                    ans.push_back(make_pair(win[1], t));
                else if(win[1] < win[2] && last == 2)
                    ans.push_back(make_pair(win[2], t));
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i ++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int s, int t){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == t){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == t){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == s || set2 == s){
            if (i < n - 1) return false;
            return (set1 == s);
        }
    }
    return false;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n){
            if (a[i] == 1) a[i] = 2;
            else a[i] = 1;
        }
        cnt = n - cnt;
    }

    if (cnt <= n - cnt){
        cout<<0;
        return 0;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt) + 1; j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    cnt = 0;
    if (ans.size() > 0){
        rep(i, 0, ans.size())
            if (i == 0 || ans[i] != ans[i-1]) cnt++;
    }
    printf("%d", cnt);
    rep(i, 0, ans.size()){
        if (i == 0 || ans[i] != ans[i-1])
            printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool check(int u, int v){
    int dema = 0, demb = 0;
    int seta = 0, setb = 0;
    rep(i, 0, n){
        if (a[i] == 1) dema ++;
        else demb++;

        if (dema == v){
            dema = demb = 0;
            seta++;
        }else if (demb == v){
            dema = demb = 0;
            setb++;
        }
        if (seta == u || setb == u){
            break;
        }
    }
    return (seta == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", a + i);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    for(int j = 1, m = sqrt(cnt); j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (check(u, v)) ans.pb(mk(u,v));
            if (u != v && check(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    rep(i, 0, ans.size()){
        printf("%d %d\n", ans[i].fi, ans[i].se);
    }

    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> res;

bool kt(int s, int t){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
        else cnt2++;

        if (cnt1 == t){
            cnt1 = cnt2 = 0;
            set1++;
        }else{
            if (cnt2 == t){
                cnt1 = cnt2 = 0;
                set2++;
            }
        }

        if (set1 == s || set2 == s){
            if (i < n - 1) return false;
            return (set1 == s);
        }
    }
    return false;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    rep(i, 0, n)
        scanf("%d", &a[i]);
    if (a[n - 1] == 2)
        rep(i, 0, n)
            a[i] = 3 - a[i];

    int k = 0;
    rep(i, 0, n)
        if (a[i] == 1) k++;

    for(int j = 1, m = sqrt(k); j <= m; j++){
        if (k % j == 0){
            int u = j;
            int v = k / u;
            if (kt(u, v)) res.pb(mk(u, v));
            if (u != v && kt(v, u)) res.pb(mk(v, u));
        }
    }
    sort(res.begin(), res.end());
    cout<<res.size();
    rep(i, 0, res.size()){
        printf("\n%d %d", res[i].fi, res[i].se);
    }
}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> res;
int cnt[N][2];

int kt(int t){
    int i = 1;
    int lo = 1, hi = n, g, res0, res1;
    int dem0 = 0, dem1 = 0;
    int last = 0;
    while (last < n){
        //cout<<last<<endl;
        if (cnt[n][0] - cnt[last][0] < t) return 0;
        if (cnt[n][0] - cnt[last][0] < t && cnt[n][1] - cnt[last][1] < t) return 0;
        lo = last + 1; hi = n;
        do{
            g = (lo + hi) >> 1;
            if (cnt[g][0] - cnt[last][0] >= t){
                res0 = g;
                hi = g - 1;
            }else lo = g + 1;
        }while (lo <= hi);
        int k = res0 - last - t;
        if (k < t){
            last = res0;
            dem0++;
            continue;
        }
        lo = last + 1; hi = n;
        do{
            g = (lo + hi) >> 1;
            if (cnt[g][1] - cnt[last][1] >= t){
                res1 = g;
                hi = g - 1;
            }else lo = g + 1;
        }while (lo <= hi);

        last = res1;
        dem1++;
        //break;
    }
    if (dem0 > dem1) return dem0;
    else return 0;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    rep(i, 0, n)
        scanf("%d", &a[i]);
    if (a[n - 1] == 2)
        rep(i, 0, n)
            a[i] = 3 - a[i];
    rep(i, 0, n){
        rep(j, 0, 2)
            cnt[i+1][j] = cnt[i][j] + (a[i] == j + 1);
    }
    //cout<<kt(1);
    //return 0;
    rep(u, 1, n + 1){
        int v = kt(u);
        if (v != 0) res.pb(mk(v, u));
    }

    sort(res.begin(), res.end());
    cout<<res.size();
    rep(i, 0, res.size()){
        printf("\n%d %d", res[i].fi, res[i].se);
    }
}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool check(int u, int v){
    int dema = 0, demb = 0;
    int seta = 0, setb = 0;
    rep(i, 0, n){
        if (a[i] == 1) dema ++;
        else demb++;

        if (dema == v){
            dema = demb = 0;
            seta++;
        }else if (demb == v){
            dema = demb = 0;
            setb++;
        }
        if (seta == u || setb == u){
            if (i < n - 1) return false;
        }
    }
    return (seta == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", a + i);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    for(int j = 1, m = sqrt(cnt); j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (check(u, v)) ans.pb(mk(u,v));
            if (u != v && check(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    rep(i, 0, ans.size()){
        printf("%d %d\n", ans[i].fi, ans[i].se);
    }

    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int s, int t){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == t){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == t){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == s || set2 == s){
            if (i < n - 1) return false;
            return (set1 == s);
        }
    }
    return false;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n){
            if (a[i] == 1) a[i] = 2;
            else a[i] = 1;
        }
        cnt = n - cnt;
    }

    if (cnt <= cnt){
        cout<<0;
        return 0;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt) + 1; j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    cnt = 0;
    if (ans.size() > 0){
        rep(i, 0, ans.size())
            if (i == 0 || ans[i] != ans[i-1]) cnt++;
    }
    printf("%d", cnt);
    rep(i, 0, ans.size()){
        if (i == 0 || ans[i] != ans[i-1])
            printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int s, int t){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == t){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == t){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == s || set2 == s){
            if (i < n - 1) return false;
            return (set1 == s);
        }
    }
    return false;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt) + 1; j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    cnt = 0;
    if (ans.size() > 0){
        rep(i, 0, ans.size())
            if (i == 0 || ans[i] != ans[i-1]) cnt++;
    }
    printf("%d", cnt);
    rep(i, 0, ans.size()){
        if (i == 0 || ans[i] != ans[i-1])
            printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int u, int v){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == v){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == v){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == u || set2 == u){
            if (i < n - 1) return false;
        }
    }
    return (set1 == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt) + 1; j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    cnt = 0;
    if (ans.size() > 0){
        rep(i, 0, ans.size())
            if (i == 0 || ans[i] != ans[i-1]) cnt++;
    }
    printf("%d\n", cnt);
    rep(i, 0, ans.size()){
        if (i == 0 || ans[i] != ans[i-1])
            printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int u, int v){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == v){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == v){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == u || set2 == u){
            if (i < n - 1) return false;
        }
    }
    return (set1 == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", a + i);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt); j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    /*rep(u, 1, 9){
        rep(v, 1, 9)
            if (check(u, v)) cout<<u;
    }*/

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    rep(i, 0, ans.size()){
        printf("%d %d\n", ans[i].fi, ans[i].se);
    }

    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> res;

bool kt(int s, int t){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
        else cnt2++;

        if (cnt1 == t){
            cnt1 = cnt2 = 0;
            set1++;
        }else{
            if (cnt2 == t){
                cnt1 = cnt2 = 0;
                set2++;
            }
        }

        if (set1 == s || set2 == s){
            if (i < n - 1) return false;
            return (set1 == s);
        }
    }
    return false;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    rep(i, 0, n)
        scanf("%d", &a[i]);
    if (a[n - 1] == 2)
        rep(i, 0, n)
            a[i] = 3 - a[i];

    int k = 0;
    rep(i, 0, n)
        if (a[i] == 1) k++;

    for(int j = 1, m = sqrt(k); j <= m; j++){
        if (k % j == 0){
            int u = j;
            int v = k / u;
            if (kt(u, v)) res.pb(mk(u, v));
            if (u != v && kt(v, u)) res.pb(mk(v, u));
        }
    }
    cout<<res.size();
    rep(i, 0, res.size()){
        printf("\n%d %d", res[i].fi, res[i].se);
    }
}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool check(int u, int v){
    int dema = 0, demb = 0;
    int seta = 0, setb = 0;
    rep(i, 0, n){
        if (a[i] == 1) dema ++;
        else demb++;
        if (dema == v){
            dema = demb = 0;
            seta++;
        }else if (demb == v){
            dema = demb = 0;
            setb++;
        }
        if (seta == u || setb == u){
            break;
        }
    }
    if (seta == u && dema == 0 && demb == 0) return true;
    else return false;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", a + i);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    for(int j = 1, m = sqrt(cnt); j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (check(u, v)) ans.pb(mk(u,v));
            if (u != v)if (check(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    rep(i, 0, ans.size()){
        printf("%d %d\n", ans[i].fi, ans[i].se);
    }

    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int u, int v){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == v){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == v){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == u || set2 == u){
            if (i < n - 1) return false;
        }
    }
    return (set1 == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt); j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    /*rep(u, 1, 9){
        rep(v, 1, 9)
            if (check(u, v)) cout<<u;
    }*/

    sort(ans.begin(), ans.end());
    printf("%d", ans.size());
    rep(i, 0, ans.size()){
        printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool check(int u, int v){
    int dema = 0, demb = 0;
    int seta = 0, setb = 0;
    rep(i, 0, n){
        if (a[i] == 1) dema ++;
        else demb++;

        if (dema == v){
            dema = 0;
            demb = 0;
            seta++;
        }else if (demb == v){
            dema = 0;
            demb = 0;
            setb++;
        }
        if (seta == u || setb == u){
            if (i < n - 1) return false;
        }
    }
    return (seta == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", a + i);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }
    if (cnt <= n - cnt){
        cout<<0;
        return 0;
    }
    if (n <= 100){
    rep(u, 1, cnt+1)
        rep(v, 1, cnt + 1)
            if (check(u, v)) ans.pb(mk(u, v));
    }else{

    for(int j = 1, m = sqrt(cnt); j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (check(u, v)) ans.pb(mk(u,v));
            if (u != v && check(v, u)) ans.pb(mk(v,u));
        }
    }}

    /*rep(u, 1, 9){
        rep(v, 1, 9)
            if (check(u, v)) cout<<u;
    }*/

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    rep(i, 0, ans.size()){
        printf("%d %d\n", ans[i].fi, ans[i].se);
    }

    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int s, int t){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == t){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == t){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set2 == s) return false;
    }
    return true;
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n){
            if (a[i] == 1) a[i] = 2;
            else a[i] = 1;
        }
        cnt = n - cnt;
    }

    if (cnt <= n - cnt){
        cout<<0;
        return 0;
    }

    ans.clear();
    for(int j = 1, k = sqrt(cnt); j <= k; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    cnt = 0;
    if (ans.size() > 0){
        rep(i, 0, ans.size())
            if (i == 0 || ans[i] != ans[i-1]) cnt++;
    }
    printf("%d", cnt);
    rep(i, 0, ans.size()){
        if (i == 0 || ans[i] != ans[i-1])
            printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 1e5 + 7;
const int M = 1e6 + 1;
const int inf = 1e9 + 7;
const double ep = 1e-9;

int a[N];
int n;
vector<ii> ans;

bool kt(int u, int v){
    int cnt1 = 0, cnt2 = 0;
    int set1 = 0, set2 = 0;
    rep(i, 0, n){
        if (a[i] == 1) cnt1++;
            else cnt2++;
        if (cnt1 == v){
            cnt1 = 0; cnt2 = 0;
            set1 ++;
        }else{
            if (cnt2 == v){
                cnt1 = 0; cnt2 = 0;
                set2++;
            }
        }

        if (set1 == u || set2 == u){
            if (i < n - 1) return false;
        }
    }
    return (set1 == u);
}

int main(){
    //freopen("out.txt", "r", stdin);
    scanf("%d", &n);
    int cnt = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
        if (a[i] == 1) cnt++;
    }
    if (a[n-1] == 2){
        rep(i, 0, n)
            a[i] = 3 - a[i];
        cnt = n - cnt;
    }

    ans.clear();
    for(int j = 1, m = sqrt(cnt) + 1; j <= m; j++){
        if (cnt % j == 0){
            int u = j, v = cnt / j;
            if (kt(u, v)) ans.pb(mk(u,v));
            if (u != v && kt(v, u)) ans.pb(mk(v,u));
        }
    }

    sort(ans.begin(), ans.end());
    printf("%d", ans.size());
    rep(i, 0, ans.size()){
        printf("\n%d %d", ans[i].fi, ans[i].se);
    }
    return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzl(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template <class T> inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}

template <class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template <class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}

template <class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2, x3), gn(x4);}

template <class T1, class T2, class T3, class T4, class T5> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5) {gn(x1, x2, x3, x4), gn(x5);}

template <class T> inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T1, class T2, class T3, class T4, class T5> inline void print(T1 x1, T2 x2, T3 x3, T4 x4, T5 x5) {printsp(x1), printsp(x2), printsp(x3), printsp(x4), println(x5);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100010

int b[NN][3];

int a[NN];

int n;

pii pa[NN];

int update(int u,int val,int st){

	if(u==0) return 0;

	for(;u<NN;u+=u&-u) b[u][st]+=val;

}

int calc(int u,int st){

	int ans=0;

	for(;u;u-=u&-u) ans+=b[u][st];

	return ans;

}

int calc_len(int u,int len,int t){

	int st=u-1;int ed=n+1;

	while(st+1<ed){

		int mid=(st+ed)/2;

		int s=calc(mid,t)-calc(u-1,t);

		if(s>=len) ed=mid;

		else st=mid;

	}

	return ed;

}

int calc_last(int u,int len){

	int ed1=calc_len(u,len,0);

	int ed2=calc_len(u,len,1);

	return min(ed1,ed2);

}

int can(int len){

	int st=0;

	int mx=0;

	int pos=1;

	while(1){

		int ed=calc_last(pos,len);

		if(ed>n) return 0;

		if(a[ed]==a[n]) st++,mx++;

		else st--;

		if(ed==n) break;

		pos=ed+1;

	}

	if(st>0) return mx;

	return 0;

}

int main(){

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	gn(n);

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

		gn(a[i]);

		a[i]--;

		update(i,1,a[i]);

	}

	update(n+1,1,0);

	update(n+1,1,1);

	update(n+2,n+2,0);

	update(n+2,n+2,1);

	int nn=0;

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

		int s=can(i);

		if(s) pa[nn++]=pii(s,i);

	}

	sort(pa,pa+nn);

	println(nn);

	for(int i=0;i<nn;i++) print(pa[i].x,pa[i].y);

}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define eps 1e-8

#define x first

#define y second

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define shit(a) (1 << (a))

#define rev(a) (power(a, mod-2, mod))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> ppi;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}

template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }

template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}

template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100011

int a[NN];

int n;

int cnt[NN][2];

vector<pii> ans;

int main() {

#ifndef	ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	cin >> n;

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

		gn(a[i]), a[i]--;

		cnt[i][0] = cnt[i-1][0];

		cnt[i][1] = cnt[i-1][1];

		cnt[i][a[i]]++;

	}

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

		int now=0, nxt;

		int s=0, t=0;

		while(now<n) {

			int st=now, ed=n+1;

			while(ed > st+1){

				int mid = st + ed >> 1;

				if(max(cnt[mid][0] - cnt[now][0], cnt[mid][1] - cnt[now][1]) >= k) ed = mid;

				else st = mid;

			}

			if(cnt[ed][0] - cnt[now][0] == k) s++;

			else t++;

			now = ed;

		}

if(s>=t and a[n]) continue;

if(s<=t and a[n]==0) continue;

		if(now == n and s!=t) ans.pb(pii(max(s, t), k));

	}

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

	println(sz(ans));

	for(int i=sz(ans); i--; ) print(ans[i].x, ans[i].y);

	return 0;

}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define eps 1e-8

#define x first

#define y second

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define shit(a) (1 << (a))

#define rev(a) (power(a, mod-2, mod))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> ppi;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}

template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }

template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}

template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100011

int a[NN];

int n;

int cnt[NN][2];

vector<pii> ans;

int main() {

#ifndef	ONLINE_JUDGE

#endif

	cin >> n;

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

		gn(a[i]), a[i]--;

		cnt[i][0] = cnt[i-1][0];

		cnt[i][1] = cnt[i-1][1];

		cnt[i][a[i]]++;

	}

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

		int now=0, nxt;

		int s=0, t=0;

		while(now<n) {

			int st=now, ed=n+1;

			while(ed > st+1){

				int mid = st + ed >> 1;

				if(max(cnt[mid][0] - cnt[now][0], cnt[mid][1] - cnt[now][1]) >= k) ed = mid;

				else st = mid;

			}

			if(cnt[ed][0] - cnt[now][0] == k) s++;

			else t++;

			now = ed;

		}

if(s>=t and a[n]) continue;

if(s<=t and a[n]==0) continue;

		if(now == n and s!=t) ans.pb(pii(max(s, t), k));

	}

	println(sz(ans));

	for(int i=sz(ans); i--; ) print(ans[i].x, ans[i].y);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 111111

int cnt[3][NN];

pii ans[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, x;

	gn(n);

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

		gn(x);

		cnt[x][i]=cnt[x][i-1]+1;

		cnt[3-x][i]=cnt[3-x][i-1];

	}

	int sco1, sco2, last, st, pos1, pos2;

	int nn=0;

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

		sco1=sco2=last=st=pos1=pos2=0;

		while(1){

			pos1=lower_bound(cnt[1], cnt[1]+n+1, cnt[1][st]+t)-cnt[1];

			pos2=lower_bound(cnt[2], cnt[2]+n+1, cnt[2][st]+t)-cnt[2];

			if(pos1>pos2)	last=2, st=pos2, sco2++;

			else			last=1, st=pos1, sco1++;

			if(st>=n) break;

		}

		if(st>n) continue;

		if(sco1==sco2) continue;

		if(last==1 and sco1<=sco2) continue;

		if(last==2 and sco2<=sco1) continue;

		ans[nn++]=pii(max(sco1, sco2), t);

	}

	sort(ans, ans+nn);

	println(nn);

	for(int i=0; i<nn; i++) print(ans[i].x, ans[i].y);

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define pb push_back

#define mod 1000000007

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=(INT)a*a%m) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 100010

int a[NN],s[NN],t[NN];

vector<pii> ans;

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	scanf("%d",&n);

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

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

		if(a[i]==1){

			s[i]=s[i-1]+1;

			t[i]=t[i-1];

		}

		else{

			s[i]=s[i-1];

			t[i]=t[i-1]+1;

		}

	}

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

		int n1=0,n2=0,flag=0,person=0;

		int st=1;

		while(true){

			if(st>n) break;

			if((s[n]-s[st-1])<k&&(t[n]-t[st-1])<k){

				flag=1;

				break;

			}

			int be=st-1,ed=n;

			while(be+1<ed){

				int mid=(be+ed)/2;

				if((s[mid]-s[st-1])>=k||(t[mid]-t[st-1])>=k) ed=mid;

				else be=mid;

			}

			if((s[ed]-s[st-1])==k){

				n1++;

				person=1;

			}

			if((t[ed]-t[st-1])==k){

				person=2;

				n2++;

			}

			st=ed+1;

		}

		if(flag) continue;

		if(n1==n2) continue;

		if((n1>n2&&person==2)||(n1<n2&&person==1)) continue;

		ans.pb(pii(max(n1,n2),k));

	}

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

	printf("%d\n",ans.size());

	for(int i=0;i<ans.size();i++) printf("%d %d\n",ans[i].x,ans[i].y);

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define pb push_back

#define mod 1000000007

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=(INT)a*a%m) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 100010

int a[NN],s[NN],t[NN];

vector<pii> ans;

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	scanf("%d",&n);

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

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

		if(a[i]==1){

			s[i]=s[i-1]+1;

			t[i]=t[i-1];

		}

		else{

			s[i]=s[i-1];

			t[i]=t[i-1]+1;

		}

	}

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

		int n1=0,n2=0,flag=0;

		int st=1;

		while(true){

			if(st>n) break;

			if((s[n]-s[st-1])<k&&(t[n]-t[st-1])<k){

				flag=1;

				break;

			}

			int be=st-1,ed=n;

			while(be+1<ed){

				int mid=(be+ed)/2;

				if((s[mid]-s[st-1])>=k||(t[mid]-t[st-1])>=k) ed=mid;

				else be=mid;

			}

			if((s[ed]-s[st-1])==k) n1++;

			if((t[ed]-t[st-1])==k) n2++;

			st=ed+1;

		}

		if(flag) continue;

		if(n1==n2) continue;

		ans.pb(pii(max(n1,n2),k));

	}

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

	printf("%d\n",ans.size());

	for(int i=0;i<ans.size();i++) printf("%d %d\n",ans[i].x,ans[i].y);

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define pb push_back

#define mod 1000000007

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=(INT)a*a%m) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 100010

int a[NN];

vector<pii> ans;

int s[NN],t[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	scanf("%d",&n);

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

		scanf("%d",&a[i]);

		if(a[i]==1){

			s[i]=s[i-1]+1;

			t[i]=t[i-1];

		}

		else{

			t[i]=t[i-1]+1;

			s[i]=s[i-1];

		}

	}

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

		int n1=0,n2=0,flag=0;

		int st=1;

		while(1){

			if(st==n+1) break;

			if((s[n]-s[st-1])<r&&(t[n]-t[st-1])<r){

				flag=1;

				break;

			}

			int be=st-1,ed=n;

			while(be+1<ed){

				int mid=(be+ed)>>1;

				if((s[mid]-s[st-1])>=r||(t[mid]-t[st-1])>=r) ed=mid;

				else be=mid;

			}

			if((s[ed]-s[st-1])==r) n1++;

			if((t[ed]-t[st-1])==r) n2++;

			st=ed+1;

		}

		if(n1==n2) continue;

		if(flag) continue;

		ans.pb(pii(max(n1,n2),r));

	}

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

	printf("%d\n",ans.size());

	for(int i=0;i<ans.size();i++) printf("%d %d\n",ans[i].x,ans[i].y);

	return 0;

}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define eps 1e-8

#define x first

#define y second

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define shit(a) (1 << (a))

#define rev(a) (power(a, mod-2, mod))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> ppi;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}

template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }

template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}

template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100011

int a[NN];

int n;

int cnt[NN][2];

vector<pii> ans;

int main() {

#ifndef	ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	cin >> n;

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

		gn(a[i]), a[i]--;

		cnt[i][0] = cnt[i-1][0];

		cnt[i][1] = cnt[i-1][1];

		cnt[i][a[i]]++;

	}

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

		int now=0, nxt;

		int s=0, t=0;

		while(now<n) {

			int st=now, ed=n+1;

			while(ed > st+1){

				int mid = st + ed >> 1;

				if(max(cnt[mid][0] - cnt[now][0], cnt[mid][1] - cnt[now][1]) >= k) ed = mid;

				else st = mid;

			}

			if(cnt[ed][0] - cnt[now][0] == k) s++;

			else t++;

			now = ed;

		}

		if(now == n and s!=t) ans.pb(pii(max(s, t), k));

	}

	println(sz(ans));

	for(int i=sz(ans); i--; ) print(ans[i].x, ans[i].y);

	return 0;

}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define eps 1e-8

#define x first

#define y second

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define shit(a) (1 << (a))

#define rev(a) (power(a, mod-2, mod))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> ppi;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}

template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }

template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}

template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100011

int a[NN];

int n;

int cnt[NN][2];

vector<pii> ans;

int main() {

#ifndef	ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	cin >> n;

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

		gn(a[i]), a[i]--;

		cnt[i][0] = cnt[i-1][0];

		cnt[i][1] = cnt[i-1][1];

		cnt[i][a[i]]++;

	}

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

		int now=0, nxt;

		int s=0, t=0;

		while(now<n) {

			int st=now, ed=n+1;

			while(ed > st+1){

				int mid = st + ed >> 1;

				if(max(cnt[mid][0] - cnt[now][0], cnt[mid][1] - cnt[now][1]) >= k) ed = mid;

				else st = mid;

			}

			if(cnt[ed][0] - cnt[now][0] == k) s++;

			else t++;

			now = ed;

		}

		if(now == n and s!=t) ans.pb(pii(max(s, t), k));

	}

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

	println(sz(ans));

	for(int i=sz(ans); i--; ) print(ans[i].x, ans[i].y);

	return 0;

}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define eps 1e-8

#define x first

#define y second

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define shit(a) (1 << (a))

#define rev(a) (power(a, mod-2, mod))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> ppi;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}

template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }

template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}

template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100011

int a[NN];

int n;

int cnt[NN][2];

vector<pii> ans;

int main() {

#ifndef	ONLINE_JUDGE

#endif

	cin >> n;

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

		gn(a[i]), a[i]--;

		cnt[i][0] = cnt[i-1][0];

		cnt[i][1] = cnt[i-1][1];

		cnt[i][a[i]]++;

	}

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

		int now=0, nxt;

		int s=0, t=0;

		while(now<n) {

			int st=now, ed=n+1;

			while(ed > st+1){

				int mid = st + ed >> 1;

				if(max(cnt[mid][0] - cnt[now][0], cnt[mid][1] - cnt[now][1]) >= k) ed = mid;

				else st = mid;

			}

			if(cnt[ed][0] - cnt[now][0] == k) s++;

			else t++;

			now = ed;

		}

if(s>=t and a[n]) continue;

if(s<=t and a[n]==0) continue;

		if(now == n and s!=t) ans.pb(pii(max(s, t), k));

	}

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

	println(sz(ans));

	for(int i=0; i<sz(ans); i++) print(ans[i].x, ans[i].y);

	return 0;

}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1,ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = -1*max1(-1*ind1,-1*ind2);

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max(s_val1,s_val2);

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

long long min1(long long a,long long b){
if(a<b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);
if(a[i]==1){
if(t_val == a2[i]){continue;}
}

if(a[i]==2){
if(t_val == a1[i]){continue;}
}

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n || j < 0){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1;
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = min1(ind1,ind2);

if(a[j]==1){
if(j == ind2){if_valid = false;break;}
}

if(a[j]==2){
if(j == ind1){if_valid = false;break;}
}

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

long long min1(long long a,long long b){
if(a<b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);
if(a[i]==1){
if(t_val == a2[i]){continue;}
}

if(a[i]==2){
if(t_val == a1[i]){continue;}
}

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n || j < 0){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1;
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = min1(ind1,ind2);

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = -1*max1(-1*ind1,-1*ind2);

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

long long min1(long long a,long long b){
if(a<b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);
if(a[i]==1){
if(t_val == a2[i]){continue;}
}

if(a[i]==2){
if(t_val == a1[i]){continue;}
}

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1;
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = min1(ind1,ind2);

if(a[j]==1)
{
if(j == ind2){if_valid = false;break;}
}

if(a[j]==2)
{
if(j == ind1){if_valid = false;break;}
}

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1;
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = -1*max1(-1*ind1,-1*ind2);

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

long long min1(long long a,long long b){
if(a<b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);
if(a[i]==1)
{
if(t_val == a2[i]){continue;}
}

if(a[i]==2)
{
if(t_val == a1[i]){continue;}
}

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1;
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = min1(ind1,ind2);

if(a[j]==1)
{
if(j == ind2){if_valid = false;break;}
}

if(a[j]==2)
{
if(j == ind1){if_valid = false;break;}
}

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);
if(a[i]==1){
if(s_val == s_val2){continue;}
}

if(a[i]==2){
if(s_val == s_val1){continue;}
}

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long max1(long long a,long long b){
if(a>b){return a;}
return b;
}

long long min1(long long a,long long b){
if(a<b){return a;}
return b;
}

int main()
{

long long n;cin >> n;
long long *a = new long long[n];
vector<long long>a1,a2;

long long cnt1,cnt2;
cnt1=  cnt2 = 0;
for(long long i  = 0;i<n;++i)
{
cin >> a[i];
if(a[i]==1){++cnt1;}
if(a[i]==2){++cnt2;}

a1.push_back(cnt1);
a2.push_back(cnt2);

}
vector<long long> s_vec;
vector<long long> t_vec;

long long md = 100001;

for(long long i =  0;i<n;++i)
{

if(a1[i]==a2[i]){continue;}

long long t_val = max1(a1[i],a2[i]);
if(a[i]==1)
{
if(t_val == a2[i]){continue;}
}

if(a[i]==2)
{
if(t_val == a1[i]){continue;}
}

long long if_valid = true;
long long j  = i;
long long s_val1 = 0;
long long s_val2 = 0;
if(a1[j] > a2[j]){++s_val1;}
if(a1[j] < a2[j]){++s_val2;}

while(true){

if(j>=n){if_valid = false;break;}

if(j==n-1){break;}

long long val1 = a1[j]+t_val;
long long val2 = a2[j]+t_val;

long long ind1 = n+1;
long long ind2 = n+1;
if(binary_search (a1.begin(), a1.end(),val1))
{
ind1 = lower_bound(a1.begin(), a1.end(),val1)-a1.begin();

}

if(binary_search (a2.begin(), a2.end(),val2))
{
ind2 = lower_bound(a2.begin(), a2.end(),val2)-a2.begin();

}

if(ind1==ind2)
{
if_valid = false;break;
}

j = min1(ind1,ind2);

if(a[j]==1)
{
if(j == ind2){if_valid = false;break;}
}

if(a[j]==2)
{
if(j == ind1){if_valid = false;break;}
}

if(ind1 < ind2){++s_val1;}
if(ind1 > ind2){++s_val2;}

}

if(s_val1==s_val2){if_valid = false;}

long long s_val = max1(s_val1,s_val2);
if(a[n-1]==1){
if(s_val == s_val2){continue;}
}

if(a[n-1]==2){
if(s_val == s_val1){continue;}
}

if(if_valid)
{

s_vec.push_back(md*s_val+t_val);

}

}

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

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

for(long long  i  = 0;i<s_vec.size();++i)
{

cout << (s_vec[i]/md) << " " << (s_vec[i]%md) << endl;

}

return 0;
}


#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <map>

#define abs(x) ((x)>=0?(x):-(x))
#define i64 long long
#define u32 unsigned int
#define u64 unsigned long long
#define clr(x,y) memset(x,y,sizeof(x))
#define CLR(x) x.clear()
#define ph(x) push(x)
#define pb(x) push_back(x)
#define SZ(x) x.size()
#define PI acos(-1.0)
#define sqr(x) ((x)*(x))
#define MP(x,y) make_pair(x,y)
#define EPS 1e-11

#define pii pair<int,int>
#define FFF freopen("test","r",stdin)
#define all(a) a.begin(),a.end()

using namespace std;

void output(i64 x)
{
    if(x<0) putchar('-'),x=-x;
    if(x==0)
    {
        putchar('0');
        return;
    }
    int a[20],num=0;
    while(x) a[++num]=x%10,x/=10;
    while(num>0) putchar('0'+a[num--]);
}

inline i64 myInt()
{
    char c=getchar();
    while(!isdigit(c)&&c!='-') c=getchar();
    int flag=1;
    if(c=='-') flag=-1,c=getchar();
    i64 x=0;
    while(isdigit(c))
    {
        x=(x*10)+(c-'0');
        c=getchar();
    }
    if(flag==-1) return -x;
    return x;
}

const int INF=1e9;
const int N=400005;

int K;

int ans;

int f[N];

int f1[N],f2[N];

int ok(int t)
{
    int curMax=0;
    int a=0,b=0;
    int cur1=0,cur2=0;

    for(int i=1;i<=K;i++)
    {

        int x=lower_bound(f1+i,f1+K+1,f1[i-1]+t)-f1;
        int y=lower_bound(f2+i,f2+K+1,f2[i-1]+t)-f2;

        if(x>K&&y>K) return 0;
        i=min(x,y);
        if(x<y) a++;
        else b++;

        if(i!=K) curMax=max(curMax,max(a,b));
    }
    if(a==b) return 0;
    ans=max(a,b);
    if(curMax==ans) return 0;

    return 1;
}

int main()
{
  //  FFF;

    K=myInt();
    for(int i=1;i<=K;i++)
    {
        int x=myInt();
        f[i]=x;
        f1[i]=f1[i-1];
        f2[i]=f2[i-1];
        if(x==1) f1[i]++;
        else f2[i]++;
    }
    set<pair<int,int> > p;

    for(int i=1;i<=K;i++)
    {
        if(ok(i))
        {
            p.insert(MP(ans,i));
        }

    }

    printf("%d\n",(int)SZ(p));
    set<pair<int,int> >::iterator it;
    for(it=p.begin();it!=p.end();it++)
    {
        printf("%d %d\n",(*it).first,(*it).second);
    }
}