#include <bits/stdc++.h>
using namespace std;
const int maxn = 1500;
int len, anssize = 0;
vector<pair<int, int> > ans;
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) const {
    return a.second > b.second;
  }
};
long long val[maxn + 1], prefix[maxn + 1], sum, big = 0;
unordered_map<long long,
              priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> >
    all;
int main() {
  all.reserve(10000000);
  cin >> len;
  for (int i = 0; i < len; ++i) cin >> val[i];
  for (int i = 1; i <= len; ++i) {
    prefix[i] = val[i - 1] + prefix[i - 1];
  }
  for (int i = 1; i <= len; ++i) {
    for (int l = 1; l <= i; ++l) {
      all[prefix[i] - prefix[l - 1]].push({l, i});
    }
  }
  for (auto &i : all) {
    vector<pair<int, int> > tmp;
    while (i.second.size()) {
      if (tmp.size() and tmp.back().second >= i.second.top().first)
        i.second.pop();
      else {
        pair<int, int> temp = i.second.top();
        i.second.pop();
        tmp.push_back(temp);
      }
    }
    if (tmp.size() > anssize) {
      ans = tmp;
      anssize = tmp.size();
    }
  }
  cout << anssize << '\n';
  for (int i = 0; i < anssize; ++i) {
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  }
}
