#include <bits/stdc++.h>
using namespace std;
long long a[1501];
map<long long, vector<pair<int, int>>> m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  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 >= 0; j--) {
      sum += a[j];
      m[sum].push_back({j, i});
    }
  }
  int r = 0;
  vector<pair<int, int>> ans;
  for (auto p : m) {
    vector<pair<int, int>> t = p.second;
    int cnt = 0;
    int R = -1;
    vector<pair<int, int>> temp;
    for (int i = 0; i < t.size(); i++) {
      if (R < t[i].first) {
        R = t[i].second;
        cnt += 1;
        temp.push_back(t[i]);
      }
    }
    if (cnt > r) {
      ans = temp;
      r = cnt;
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
  }
  return 0;
}
