#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
void open() {
  ((void)0);
  ((void)0);
  ((void)0);
}
const int MAX = 1500;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1);
const long double ERR = 1e-10;
const int move_r[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int move_c[] = {0, -1, 0, 1, -1, 1, -1, 1};
map<int, vector<pair<int, int>>> mp;
int mx, mx_idx, N, A[MAX + 1];
bool cmp(pair<int, int> &a, pair<int, int> &b) {
  if (a.second == b.second) return a.first > b.first;
  return a.second < b.second;
}
int main(int argc, char *argv[]) {
  open();
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", A + i);
    A[i] += A[i - 1];
  }
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      mp[A[j] - A[i]].push_back({i + 1, j});
    }
  }
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    if (it->second.size() <= mx) continue;
    sort(it->second.begin(), it->second.end(), cmp);
    vector<int> rm;
    for (int i = 0, last = 0; i < it->second.size(); ++i) {
      while (i < it->second.size() && it->second[i].first <= last)
        rm.push_back(i++);
      last = it->second[i].second;
    }
    while (!rm.empty()) {
      it->second.erase(it->second.begin() + rm.back());
      rm.pop_back();
    }
    if (mx < it->second.size()) {
      mx = it->second.size();
      mx_idx = it->first;
    }
  }
  printf("%d\n", mx);
  vector<pair<int, int>> &v = mp[mx_idx];
  for (pair<int, int> p : v) printf("%d %d\n", p.first, p.second);
  return 0;
}
