#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.second != b.second) return a.second < b.second;
  return a.first < b.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, j;
  cin >> n;
  long long int h[1505];
  for (i = 1; i <= n; i++) {
    cin >> h[i];
  }
  map<long long int, vector<pair<long long int, long long int>>> mp;
  for (i = 1; i <= n; i++) {
    long long int sum = 0;
    for (j = i; j >= 1; j--) {
      sum = sum + h[j];
      mp[sum].push_back({j, i});
    }
  }
  vector<pair<long long int, long long int>> ans_v;
  long long int ans;
  long long int max1 = 0;
  vector<pair<long long int, long long int>> v;
  for (auto &x : mp) {
    long long int sum = x.first;
    v = x.second;
    long long int prev_end = -1;
    j = 0;
    long long int cnt = 0;
    long long int k = v.size();
    vector<pair<long long int, long long int>> pos;
    while (j < k) {
      if (v[j].first > prev_end) {
        cnt++;
        prev_end = v[j].second;
        pos.emplace_back(v[j]);
      }
      ++j;
    }
    if (max1 < cnt) {
      max1 = cnt;
      ans = sum;
      ans_v = pos;
    }
  }
  cout << max1 << "\n";
  for (i = 0; i < ans_v.size(); ++i) {
    cout << ans_v[i].first << " " << ans_v[i].second << "\n";
  }
  return 0;
}
