#include <bits/stdc++.h>
using namespace std;
const int ms = 2e3 + 10;
map<int, vector<pair<int, int>>> mp;
int n, a[ms], go[ms * ms], dp[ms * ms];
int get(int i, vector<pair<int, int>> &v) {
  if (i == v.size()) {
    return 0;
  }
  int &ans = dp[i];
  if (ans != -1) return ans;
  int next = lower_bound(v.begin(), v.end(), make_pair(v[i].second + 1, -1)) -
             v.begin();
  int v1 = get(i + 1, v), v2 = 1 + get(next, v);
  if (v1 <= v2) go[i] = next;
  ans = max(v1, v2);
  return ans;
}
vector<pair<int, int>> solve(vector<pair<int, int>> &v) {
  for (int i = 0; i < v.size(); i++) dp[i] = go[i] = -1;
  get(0, v);
  vector<pair<int, int>> ans;
  for (int i = 0; i < v.size();) {
    if (go[i] != -1) {
      ans.push_back(v[i]);
      i = go[i];
    } else
      i++;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int sum = 0;
    for (int j = i; j >= 0; j--) {
      sum += a[j];
      mp[sum].push_back({j, i});
    }
  }
  vector<pair<int, int>> ans;
  for (auto now : mp) {
    vector<pair<int, int>> v = now.second;
    sort(v.begin(), v.end());
    vector<pair<int, int>> tans = solve(v);
    if (tans.size() > ans.size()) ans = tans;
  }
  cout << ans.size() << endl;
  for (auto pp : ans) cout << 1 + pp.first << " " << 1 + pp.second << endl;
  return 0;
}
