#include <bits/stdc++.h>
using namespace std;
const int maxn = 1505;
int n, a[maxn], sum[maxn], ans, val, ID;
int d[maxn * maxn], cnt;
vector<int> v[maxn * maxn];
vector<int> vv[maxn];
unordered_map<int, int> mp, L[maxn];
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 - 1; ~j; j--) {
      int t = sum[i] - sum[j];
      d[++cnt] = t;
      if (!L[i][t]) L[i][t] = j + 1, vv[i].push_back(t);
    }
  }
  sort(d + 1, d + 1 + cnt);
  cnt = unique(d + 1, d + 1 + cnt) - d - 1;
  for (int i = 1; i <= cnt; i++) mp[d[i]] = i;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < vv[i].size(); j++) {
      int t = vv[i][j], id = mp[t];
      if (v[id].empty() || v[id].back() < L[i][t]) {
        v[id].push_back(i);
      }
      if (ans < v[id].size()) {
        ans = v[id].size();
        val = t;
        ID = id;
      }
    }
  }
  printf("%d\n", ans);
  for (int i : v[ID]) {
    printf("%d %d\n", L[i][val], i);
  }
  return 0;
}
