#include <bits/stdc++.h>
using namespace std;
int a[1501], N;
map<int, vector<pair<int, int> > > Map;
void build_map() {
  for (int r = 1; r <= N; r++) {
    int sum = 0;
    for (int l = r; l >= 1; l--) {
      sum += a[l];
      Map[sum].push_back(make_pair(l, r));
    }
  }
}
void find_max() {
  int res = 1, mark = a[1];
  for (auto it = Map.begin(); it != Map.end(); it++) {
    int r = -1, sum = 0;
    for (int j = 0; j < it->second.size(); j++) {
      if (it->second[j].first > r) sum++, r = it->second[j].second;
    }
    if (sum > res) res = sum, mark = it->first;
  }
  cout << res << '\n';
  int r = -1;
  for (int j = 0; j < Map[mark].size(); j++)
    if (Map[mark][j].first > r)
      cout << Map[mark][j].first << " " << Map[mark][j].second << '\n',
          r = Map[mark][j].second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> a[i];
  build_map();
  find_max();
  return 0;
}
