#include <bits/stdc++.h>
using namespace std;
int n, k, a[1505], sum[1505], ans = 0, pos, cnt = 0;
struct Node {
  int l, r, v;
  Node() {}
  Node(int a, int b, int c) { l = a, r = b, v = c; }
} shit[1505 * 1505];
int query(int l, int r) { return sum[r] - sum[l - 1]; }
bool cmp(Node a, Node b) {
  if (a.v == b.v) {
    if (a.r == b.r) return a.l > b.l;
    return a.r < b.r;
  }
  return a.v < b.v;
}
bool cmp2(Node a, Node b) {
  if (a.v == b.v) {
    if (a.r == b.r) return a.l < b.l;
    return a.r > b.r;
  }
  return a.v < b.v;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      shit[++cnt] = Node(i, j, query(i, j));
    }
  }
  int nans = 0, xpos = 1;
  shit[0].v = 0x3f3f3f3f;
  sort(shit + 1, shit + cnt + 1, cmp);
  for (int i = 1; i <= cnt; i++) {
    if (shit[i - 1].v != shit[i].v) {
      if (ans < nans) ans = nans, xpos = i - 1;
      nans = 1;
      pos = shit[i].r;
      continue;
    }
    if (pos < shit[i].l) {
      pos = shit[i].r;
      nans++;
    }
  }
  if (ans < nans) ans = nans, xpos = cnt;
  ans = max(ans, nans);
  printf("%d\n", ans);
  sort(shit + 1, shit + cnt + 1, cmp2);
  pos = shit[xpos].r;
  printf("%d %d\n", shit[xpos].l, shit[xpos].r);
  for (int i = xpos - 1; shit[i].v == shit[i + 1].v; i--) {
    if (pos < shit[i].l) {
      pos = shit[i].r;
      printf("%d %d\n", shit[i].l, shit[i].r);
    }
  }
  return 0;
}
