#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1501;
int a[maxn];
map<int, vector<pair<int, int>>> sums;
int main() {
  int n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long r = 0; r < n; r++) {
    long long sum = 0;
    for (long long l = r; l >= 0; l--) {
      sum += a[l];
      sums[sum].push_back(make_pair(l, r));
    }
  }
  vector<pair<int, int>> ans;
  int max_ans = 0;
  for (auto& i : sums) {
    vector<pair<int, int>> candidate;
    int r = -1;
    for (auto block : i.second) {
      if (block.first > r) {
        candidate.push_back(block);
        r = block.second;
      }
    }
    if (((int)candidate.size()) > max_ans) {
      ans = candidate;
      max_ans = ((int)candidate.size());
    }
  }
  cout << max_ans << endl;
  for (auto i : ans) {
    cout << i.first + 1 << " " << i.second + 1 << endl;
  }
  return 0;
}
