#include <bits/stdc++.h>
using namespace std;
int n, a[1510];
map<int, vector<pair<int, int>>> sums, ansList;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    int sumCur = 0;
    for (int j = i; j <= n; j++) {
      sumCur = sumCur + a[j];
      sums[sumCur].push_back({i, j});
    }
  }
  for (auto it : sums) {
    int sumCur = it.first;
    vector<pair<int, int>> sumsTemp = it.second;
    ansList[sumCur].push_back(sumsTemp[0]);
    for (int j = 1; j < sumsTemp.size(); j++) {
      if (sumsTemp[j].first > ansList[sumCur].back().second) {
        ansList[sumCur].push_back(sumsTemp[j]);
      } else if (ansList[sumCur].back().second > sumsTemp[j].second) {
        ansList[sumCur].pop_back();
        ansList[sumCur].push_back(sumsTemp[j]);
      }
    }
  }
  int sumCntMax = 0, sumCur;
  for (auto it : ansList) {
    if (it.second.size() > sumCntMax) {
      sumCntMax = it.second.size();
      sumCur = it.first;
    }
  }
  cout << sumCntMax << endl;
  for (int i = 0; i < ansList[sumCur].size(); i++) {
    cout << ansList[sumCur][i].first << " " << ansList[sumCur][i].second
         << endl;
  }
}
