#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int A[maxn], a[maxn], b[maxn];
vector<pair<int, int> > ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1], b[i] = b[i - 1];
    if (A[i - 1] == 1)
      a[i]++;
    else
      b[i]++;
  }
  for (int t = 1; t <= n; t++) {
    int l = 0, w1 = 0, w2 = 0, can = 1, lst = 0;
    while (l < n && can) {
      int lo = l, hi = n + 1;
      while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        int t1 = a[mid] - a[l];
        int t2 = b[mid] - b[l];
        if (t1 >= t || t2 >= t)
          hi = mid;
        else
          lo = mid;
      }
      if (hi == n + 1) {
        can = 0;
        break;
      }
      if (a[hi] - a[l] > b[hi] - b[l])
        w1++, lst = 1;
      else
        w2++, lst = 2;
      l = hi;
    }
    if (!can || w1 == w2 || l != n) continue;
    if ((w1 > w2 && lst == 2) || (w2 > w1 && lst == 1)) continue;
    ans.push_back({max(w1, w2), t});
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (pair<int, int> t : ans) cout << t.first << " " << t.second << '\n';
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total of s sets, he wins the match and the match is over. Here s and t are some positive integer numbers.

To spice it up, Petya and Gena choose new numbers s and t before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores t points and the match is over as soon as one of the players wins s sets.

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numbers s and t for the given match are also lost. The players now wonder what values of s and t might be. Can you determine all the possible options?

Input

The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105).

The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena.

It is not guaranteed that at least one option for numbers s and t corresponds to the given record.

Output

In the first line print a single number k — the number of options for numbers s and t.

In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.

Examples

Input

5
1 2 1 2 1


Output

2
1 3
3 1


Input

4
1 1 1 1


Output

3
1 4
2 2
4 1


Input

4
1 2 1 2


Output

0


Input

8
2 1 2 1 1 1 1 1


Output

3
1 6
2 3
6 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int A[maxn], a[maxn], b[maxn];
vector<pair<int, int> > ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1], b[i] = b[i - 1];
    if (A[i - 1] == 1)
      a[i]++;
    else
      b[i]++;
  }
  for (int t = 1; t <= n; t++) {
    int l = 0, w1 = 0, w2 = 0, can = 1, lst = 0;
    while (l < n && can) {
      int lo = l, hi = n + 1;
      while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        int t1 = a[mid] - a[l];
        int t2 = b[mid] - b[l];
        if (t1 >= t || t2 >= t)
          hi = mid;
        else
          lo = mid;
      }
      if (hi == n + 1) {
        can = 0;
        break;
      }
      if (a[hi] - a[l] > b[hi] - b[l])
        w1++, lst = 1;
      else
        w2++, lst = 2;
      l = hi;
    }
    if (!can || w1 == w2 || l != n) continue;
    if ((w1 > w2 && lst == 2) || (w2 > w1 && lst == 1)) continue;
    ans.push_back({max(w1, w2), t});
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (pair<int, int> t : ans) cout << t.first << " " << t.second << '\n';
}

```