#include <bits/stdc++.h>
using namespace std;
struct Pair {
  int l, r;
  bool operator<(const Pair &p) const {
    if (r != p.r) return (r < p.r);
    return (l < p.l);
  }
};
vector<Pair> adj[3002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  map<int, int> M;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      sum += A[j];
      if (!M.count(sum)) {
        M[sum] = cnt++;
      }
      adj[M[sum]].push_back({i, j});
    }
  }
  for (int i = 0; i < cnt; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  int ans = 0, id = 0;
  for (int i = 0; i < cnt; i++) {
    int cur = 1, last = adj[i][0].r;
    for (int j = 1; j < adj[i].size(); j++) {
      if (adj[i][j].l > last) {
        last = adj[i][j].r;
        cur++;
      }
    }
    if (cur > ans) {
      ans = cur;
      id = i;
    }
  }
  cout << ans << endl;
  int last = adj[id][0].r;
  cout << adj[id][0].l + 1 << " " << adj[id][0].r + 1 << endl;
  for (int i = 1; i < adj[id].size(); i++) {
    if (adj[id][i].l > last) {
      cout << adj[id][i].l + 1 << " " << adj[id][i].r + 1 << endl;
      last = adj[id][i].r;
    }
  }
  cout << endl;
}
