#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> P[2];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    P[--A[i]].push_back(i);
  }
  vector<int> S[2];
  for (int i = 0; i < 2; i++) {
    S[i].resize(N + 1, 0);
    for (auto it = P[i].begin(); it != P[i].end(); it++) S[i][*it + 1]++;
    for (int j = 0; j < N; j++) S[i][j + 1] += S[i][j];
  }
  set<pair<int, int> > ans;
  vector<pair<int, int> > V;
  for (int i = 0; i < N; i++) V.push_back(make_pair(i + 1, A[i]));
  int W[2] = {0, 0};
  for (auto it = V.begin(); it != V.end(); it++) W[it->second]++;
  if (W[A[N - 1]] > W[1 - A[N - 1]]) ans.insert(make_pair(W[A[N - 1]], 1));
  for (int t = 2; t <= N; t++) {
    int a = 0;
    for (unsigned int i = 0; i < V.size(); i++) {
      V[i].first = max(V[i].first, a);
      while (V[i].first <= N && -S[0][a] + S[0][V[i].first] < t &&
             -S[1][a] + S[1][V[i].first] < t)
        V[i].first++;
      if (V[i].first > N) {
        V.resize(i);
        break;
      }
      if (-S[1 - A[V[i].first - 1]][a] + S[1 - A[V[i].first - 1]][V[i].first] <
          t)
        V[i].second = A[V[i].first - 1];
      else
        V[i].second = 1 - A[V[i].first - 1];
      a = V[i].first;
    }
    if (V.empty() || V.rbegin()->first != N) continue;
    W[0] = W[1] = 0;
    for (auto it = V.begin(); it != V.end(); it++) W[it->second]++;
    if (W[A[N - 1]] > W[1 - A[N - 1]]) ans.insert(make_pair(W[A[N - 1]], t));
  }
  cout << ans.size() << "\n";
  for (auto it = ans.begin(); it != ans.end(); it++)
    cout << it->first << " " << it->second << "\n";
  return 0;
}
