#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<long long, vector<pair<int, int>>> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = i; j < n; j++) {
      sum += a[j];
      d[sum].push_back({i, j});
    }
  }
  pair<int, vector<pair<int, int>>> opt = {-INT_MAX, {}};
  for (auto it : d) {
    sort(it.second.begin(), it.second.end(),
         [](pair<int, int> p1, pair<int, int> p2) {
           return p1.second < p2.second;
         });
    pair<int, int> prev = it.second[0];
    pair<int, vector<pair<int, int>>> cur = {1, {prev}};
    for (int i = 1; i < it.second.size(); i++) {
      if (it.second[i].first > prev.second) {
        cur.second.push_back(it.second[i]);
        cur.first++;
        prev = it.second[i];
      }
    }
    opt = max(opt, cur);
  }
  cout << opt.first << endl;
  for (int i = 0; i < opt.first; i++) {
    cout << opt.second[i].first + 1 << " " << opt.second[i].second + 1 << endl;
  }
}
