#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n + 1);
  long long i;
  for (i = 1; i <= n; i++) cin >> v[i];
  map<long long, vector<pair<long long, long long> > > mp, upd;
  long long r, l;
  for (r = 1; r <= n; r++) {
    long long sum = 0;
    for (l = r; l >= 1; l--) {
      sum += v[l];
      mp[sum].push_back(make_pair(l, r));
    }
  }
  map<long long, vector<pair<long long, long long> > >::iterator it;
  pair<long long, long long> mt = make_pair(0, 0);
  for (it = mp.begin(); it != mp.end(); it++) {
    long long t = it->first;
    long long rt = -1;
    long long curr = 0;
    for (i = 0; i < mp[t].size(); i++) {
      if (mp[t][i].first > rt) {
        curr++;
        upd[t].push_back(mp[t][i]);
        rt = mp[t][i].second;
      }
    }
    if (curr > mt.second) {
      mt.first = t;
      mt.second = curr;
    }
  }
  cout << mt.second << endl;
  for (i = 0; i < upd[mt.first].size(); i++) {
    cout << upd[mt.first][i].first << " " << upd[mt.first][i].second << endl;
  }
}
