#include <bits/stdc++.h>
using namespace std;
int N, DP[1600], dp[(1500 * 1500)], pad[(1500 * 1500)];
vector<pair<int, int> > Generate(vector<pair<int, int> > &v) {
  sort(v.begin(), v.end());
  vector<pair<int, int> > R;
  int L = v.size();
  for (int i = 0; i < L; i++) dp[i] = 0, pad[i] = -1;
  int maxp = 0;
  for (int i = 0; i < L; i++) {
    if (i > 0 && dp[i - 1] > dp[i]) dp[i] = dp[i - 1], pad[i] = pad[i - 1];
    int l = i, r = L;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (v[m].first > v[i].second)
        r = m;
      else
        l = m;
    }
    if (dp[r] < dp[i] + 1) dp[r] = dp[i] + 1, pad[r] = i;
    if (dp[i] > dp[maxp]) maxp = i;
  }
  while (maxp > -1) {
    R.push_back(v[maxp]);
    maxp = pad[maxp];
  }
  return R;
}
int main() {
  cin >> N >> DP[1];
  map<int, vector<pair<int, int> > > mapa;
  mapa[DP[1]].push_back({1, 1});
  for (int i = 2; i <= N; i++) {
    int a;
    cin >> a;
    DP[i] = DP[i - 1] + a;
    for (int j = 0; j < i; j++) {
      int ij = DP[i] - DP[j];
      mapa[ij].push_back({j + 1, i});
    }
  }
  vector<pair<int, int> > Res;
  for (auto &k : mapa) {
    vector<pair<int, int> > LR = Generate(k.second);
    if (LR.size() > Res.size()) Res = LR;
  }
  cout << Res.size() << endl;
  for (auto k : Res) {
    printf("%d %d\n", k.first, k.second);
  }
}
