#include <bits/stdc++.h>
using namespace std;
const int N = 1507, M = N * N;
int sum[N], n, m, i, j, ind;
vector<pair<int, int> > e[M], ans, tmp;
map<int, int> mp;
pair<int, int> now;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int id(int x) {
  if (!mp[x]) mp[x] = ++ind;
  return mp[x];
}
void go(vector<pair<int, int> >& e) {
  sort(e.begin(), e.end(), cmp);
  now = pair<int, int>(0, 0);
  tmp.clear();
  for (auto& x : e)
    if (x.first > now.second) tmp.push_back(now = x);
  if (tmp.size() > ans.size()) ans = tmp;
}
int main() {
  for (scanf("%d", &n), i = 1; i <= n; ++i)
    scanf("%d", sum + i), sum[i] += sum[i - 1];
  for (i = 1; i <= n; ++i)
    for (j = 0; j < i; ++j)
      e[id(sum[i] - sum[j])].push_back(pair<int, int>(j + 1, i));
  for (i = 1; i <= ind; ++i) go(e[i]);
  printf("%d\n", int(ans.size()));
  for (auto& x : ans) printf("%d %d\n", x.first, x.second);
}
