#include <bits/stdc++.h>
using namespace std;
int a[1510], s[1510][1510], ans[1510 * 1510 / 2], flag[1510 * 1510 / 2];
struct seg {
  int l, r, sum;
} sa[1510 * 1510 / 2], res[1510 * 1510 / 2];
bool cmp(const seg &x, const seg &y) {
  if (x.sum < y.sum) return 1;
  if (x.sum > y.sum) return 0;
  return x.r < y.r;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], s[i][i] = a[i];
  int k = 1;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++, k++) {
      s[i][j] = s[i][j - 1] + a[j];
      sa[k].l = i;
      sa[k].r = j;
      sa[k].sum = s[i][j];
    }
  --k;
  sort(sa + 1, sa + k + 1, cmp);
  int l1 = 1, r1 = 1, i = 0;
  while (r1 <= k) {
    i++;
    while (sa[r1].sum == sa[l1].sum) r1++;
    r1--;
    res[i].l = l1;
    res[i].r = r1;
    int check = sa[l1].r;
    ans[i] = 1;
    flag[l1] = 1;
    for (int j = l1 + 1; j <= r1; j++)
      if (sa[j].l > check && sa[j].r != 0) {
        check = sa[j].r;
        ans[i]++;
        flag[j] = 1;
      }
    l1 = r1 + 1;
    r1 += 1;
  }
  int sn = i, maxn = 0, maxi;
  for (i = 1; i <= sn; i++)
    if (ans[i] > maxn) {
      maxn = ans[i];
      maxi = i;
    }
  cout << maxn << endl;
  for (int i = res[maxi].l; i <= res[maxi].r; i++)
    if (flag[i] == 1 && sa[i].l != 0) cout << sa[i].l << " " << sa[i].r << endl;
  return 0;
}
