#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 1501;
int arr[MAXN];
map<int, vector<ii>> G;
bool cmp(ii x, ii y) { return x.second < y.second; }
int b1[MAXN], b2[MAXN], n;
void update(int idx, int k, int fw[]) {
  for (; idx <= n; idx += (idx & -idx)) fw[idx] += k;
}
int sum(int idx, int fw[]) {
  int res = 0;
  for (; idx; idx -= (idx & -idx)) res += fw[idx];
  return res;
}
void range_update(int l, int r, int k) {
  update(l, k, b1);
  update(r + 1, -k, b1);
  update(l, k * (l - 1), b2);
  update(r + 1, -k * r, b2);
}
inline int psum(int idx) { return sum(idx, b1) * idx - sum(idx, b2); }
inline int rsq(int l, int r) { return psum(r) - psum(l - 1); }
int32_t main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> arr[i];
  }
  int cur;
  for (int i = 0; i < (n); ++i) {
    cur = 0;
    for (int j = i; j < (n); ++j) {
      cur += arr[j];
      G[cur].push_back({i + 1, j + 1});
    }
  }
  vector<ii> kp, tmp;
  for (auto&& v : G) {
    sort(v.second.begin(), v.second.end(), cmp);
    memset(b1, 0, sizeof b1);
    memset(b2, 0, sizeof b2);
    tmp.clear();
    for (auto& p : v.second) {
      if (!rsq(p.first, p.second)) {
        range_update(p.first, p.second, 1);
        tmp.push_back(p);
      }
    }
    if (tmp.size() > kp.size()) {
      swap(tmp, kp);
    }
  }
  cout << kp.size() << '\n';
  for (auto p : kp) {
    cout << p.first << ' ' << p.second << '\n';
  }
}
