#include <bits/stdc++.h>
using namespace std;
const long long prime = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, a[1505], sum, r, l, rtemp, kmax = 0, ksum;
  map<long long, set<pair<long long, long long>>> seg_r_l, seg_l_r;
  set<long long> sums;
  cin >> n;
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    cin >> a[i];
  }
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    sum = 0;
    for (long long j = (long long)(i); j <= (long long)(n); j++) {
      sum += a[j];
      sums.insert(sum);
      seg_r_l[sum].insert(make_pair(j, i));
    }
  }
  for (auto it1 = sums.begin(); it1 != sums.end(); it1++) {
    r = 0;
    if (seg_r_l[(*it1)].size() <= kmax) {
      continue;
    }
    for (auto it2 = seg_r_l[(*it1)].begin(); it2 != seg_r_l[(*it1)].end();
         it2++) {
      l = (*it2).second;
      rtemp = (*it2).first;
      if (l > r) {
        seg_l_r[(*it1)].insert(make_pair(l, rtemp));
        r = rtemp;
      }
    }
    if (seg_l_r[(*it1)].size() > kmax) {
      kmax = seg_l_r[(*it1)].size();
      ksum = (*it1);
    }
  }
  cout << kmax << endl;
  for (auto it = seg_l_r[ksum].begin(); it != seg_l_r[ksum].end(); it++) {
    cout << (*it).first << " " << (*it).second << endl;
  }
}
