#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[100007], sum = 0, k = 0, x;
  map<long long, long long> m, mp, mv;
  vector<vector<pair<long long, long long> > > vi(7000007);
  map<long long, long long>::iterator it;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    sum = 0;
    for (long long j = i; j <= n; j++) {
      sum += a[j];
      if (m.find(sum) != m.end()) {
        if (i > mp[sum]) {
          mp[sum] = j;
          m[sum]++;
          x = mv[sum];
          vi[x].push_back({i, j});
        } else if (j <= mp[sum]) {
          mp[sum] = j;
          x = mv[sum];
          vi[x].pop_back();
          vi[x].push_back({i, j});
        }
      } else {
        m[sum]++;
        mp[sum] = j;
        mv[sum] = k;
        vi[k].push_back({i, j});
        k++;
      }
    }
  }
  long long mx = 0;
  sum = 0;
  for (it = m.begin(); it != m.end(); it++) {
    if (it->second > mx) {
      mx = it->second;
      sum = it->first;
    }
  }
  cout << mx << endl;
  x = mv[sum];
  for (int i = 0; i < vi[x].size(); i++) {
    cout << vi[x][i].first << " " << vi[x][i].second << endl;
  }
  return 0;
}
