#include <bits/stdc++.h>
using namespace std;
const int maxn = 1505;
int n;
long long sum[maxn];
map<long long, int> mp;
int indx;
vector<pair<int, int> > lst[maxn * maxn];
bool cmp(const vector<pair<int, int> > &v1, const vector<pair<int, int> > &v2) {
  return v1.size() > v2.size();
}
int sol(int id, bool output) {
  int cnt = 0, lastR = 0;
  for (pair<int, int> p : lst[id])
    if (p.first > lastR) {
      cnt++;
      lastR = p.second;
      if (output) printf("%d %d\n", p.first, p.second);
    }
  return cnt;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &sum[i]), sum[i] += sum[i - 1];
  for (int r = 1; r <= n; r++)
    for (int l = r; l >= 1; l--) {
      int t = sum[r] - sum[l - 1];
      if (mp.find(t) == mp.end()) mp[t] = indx++;
      lst[mp[t]].push_back({l, r});
    }
  sort(lst, lst + indx, cmp);
  int ans = 0, which = 0;
  for (int i = 0; i < indx; i++) {
    if (ans >= lst[i].size()) break;
    int t = sol(i, false);
    if (t > ans) ans = t, which = i;
  }
  printf("%d\n", ans);
  sol(which, true);
  return 0;
}
