#include <bits/stdc++.h>
using namespace std;
const int N = 1500 + 5;
map<int, vector<pair<int, int> > > rec;
int n, a[N], pre[N * N], lis[N * N];
bool cmp(pair<int, int> x, pair<int, int> y) { return x.second < y.second; }
map<int, vector<int> > rem;
vector<pair<int, int> > SelectMaxNum(vector<pair<int, int> >& v) {
  if (!v.size()) return vector<pair<int, int> >();
  sort(v.begin(), v.end(), cmp);
  vector<pair<int, int> > ans;
  int pos = v[0].second;
  ans.push_back(v[0]);
  for (int i = 1; i < v.size(); i++) {
    if (v[i].first > pos) pos = v[i].second, ans.push_back(v[i]);
  }
  return ans;
}
int main() {
  std::cin >> n;
  for (int i = 1; i <= n; i++) std::cin >> a[i];
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = i; j <= n; j++) sum += a[j], rec[sum].push_back({i, j});
  }
  vector<pair<int, int> > outp;
  int ans = 0;
  for (map<int, vector<pair<int, int> > >::iterator it = rec.begin();
       it != rec.end(); ++it) {
    vector<pair<int, int> > v = it->second;
    vector<pair<int, int> > tans = SelectMaxNum(v);
    if (ans < tans.size()) ans = tans.size(), outp = tans;
  }
  cout << ans << endl;
  for (auto t : outp) cout << t.first << " " << t.second << endl;
  return 0;
}
