#include <bits/stdc++.h>
using namespace std;
const double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);
int irand(int lo, int hi) {
  return (((double)rand()) / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;
}
string toString(long long x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
long long toNumber(string S) {
  long long ret;
  sscanf(S.c_str(), "%lld", &ret);
  return ret;
}
const int INF = (int)2e9;
const long long MOD = (long long)1e9 + 7;
pair<int, int> temp[1500 * 1500 + 5];
pair<int, int> maxx[1500 * 1500 + 5];
int solve(vector<pair<int, int> >& dat, vector<pair<int, int> >& res) {
  int sz = (int)dat.size();
  dat.push_back(make_pair(INF, INF));
  temp[sz] = make_pair(0, INF);
  maxx[sz] = make_pair(0, sz);
  for (int i = sz - 1; i >= 0; i--) {
    int idx =
        lower_bound(dat.begin(), dat.end(), make_pair(dat[i].second + 1, 0)) -
        dat.begin();
    temp[i] = make_pair(maxx[idx].first + 1, maxx[idx].second);
    maxx[i] = maxx[i + 1];
    if (temp[i] > maxx[i] || (temp[i] == maxx[i]))
      maxx[i] = make_pair(temp[i].first, i);
  }
  if ((int)res.size() >= maxx[0].first) return 0;
  res.clear();
  for (int idx = maxx[0].second; idx < sz; idx = temp[idx].second)
    res.push_back(dat[idx]);
  return maxx[0].first;
}
map<int, int> hashh;
vector<vector<pair<int, int> > > slot;
int dat[1505];
int main() {
  int n;
  scanf("%d", &n);
  dat[0] = 0;
  for (int i = 1; i <= n; i += 1) scanf("%d", dat + i), dat[i] += dat[i - 1];
  for (int i = 1; i <= n; i += 1)
    for (int j = i; j <= n; j += 1) {
      if (hashh.find(dat[j] - dat[i - 1]) == hashh.end()) {
        hashh[dat[j] - dat[i - 1]] = (int)slot.size();
        slot.push_back(vector<pair<int, int> >());
      }
      slot[hashh[dat[j] - dat[i - 1]]].push_back(make_pair(i, j));
    }
  vector<pair<int, int> > res;
  res.clear();
  for (pair<int, int> x : hashh) solve(slot[x.second], res);
  printf("%d\n", (int)res.size());
  for (pair<int, int> x : res) printf("%d %d\n", x.first, x.second);
  return 0;
}
