#include <bits/stdc++.h>
using namespace std;
int a[1505], b[1505], c[1505];
vector<pair<int, int>> vp[1505 * 1505];
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  int n, k = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    int sm = 0;
    for (int j = i; j <= n; j++) {
      sm += a[j];
      if (mp[sm] == 0) {
        mp[sm] = ++k;
      }
      vp[mp[sm]].push_back(make_pair(j, i));
    }
  }
  int pos = 0, best = 0;
  for (int i = 1; i <= k; i++) {
    int ans = 0, lst = 0;
    sort(vp[i].begin(), vp[i].end());
    for (int j = 0; j < vp[i].size(); j++) {
      pair<int, int> P = vp[i][j];
      if (P.second > lst) {
        ans++;
        lst = P.first;
      }
    }
    if (ans > best) {
      best = ans;
      pos = i;
    }
  }
  cout << best << '\n';
  int lol = 0;
  for (int i = 0; i < vp[pos].size(); i++) {
    pair<int, int> P = vp[pos][i];
    if (P.second > lol) {
      cout << P.second << " " << P.first << '\n';
      lol = P.first;
    }
  }
  return 0;
}
