#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  unordered_map<int, vector<pair<int, int>>> sum2pairs;
  for (int r = 0; r < (n); r++) {
    int sum = 0;
    for (int l = r; l >= 0; l--) {
      sum += a[l];
      sum2pairs[sum].push_back({l, r});
    }
  }
  vector<pair<int, int>> answer;
  for (auto& it : sum2pairs) {
    vector<pair<int, int>> now;
    int last = -1;
    for (auto& p : it.second) {
      if (p.first > last) {
        last = p.second;
        now.push_back(p);
      }
    }
    if (now.size() > answer.size()) {
      answer = move(now);
    }
  }
  cout << (answer.size()) << endl;
  for (int i = 0; i < (answer.size()); i++) {
    cout << answer[i].first + 1 << " " << answer[i].second + 1 << endl;
  }
  return 0;
}
