#include <bits/stdc++.h>
using namespace std;
const int N = 1505;
map<int, int> mp;
int id;
int n, ara[N];
vector<pair<int, int>> g[N * N];
int ID;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ara[i];
  for (int i = 1; i <= n; i++) {
    int s = 0;
    for (int j = i; j <= n; j++) {
      s += ara[j];
      if (mp[s] == 0) {
        mp[s] = ++id;
      }
      g[mp[s]].push_back(make_pair(j, i));
    }
  }
  int mx = 0;
  for (int i = 1; i <= id; i++) {
    int done = 0;
    sort(g[i].begin(), g[i].end());
    int ans = 0;
    for (int j = 0; j < g[i].size(); j++) {
      pair<int, int> P = g[i][j];
      if (P.second > done) {
        ans++;
        done = P.first;
      }
    }
    if (ans > mx) {
      mx = ans;
      ID = i;
    }
  }
  cout << mx << "\n";
  int done = 0;
  for (int j = 0; j < g[ID].size(); j++) {
    pair<int, int> P = g[ID][j];
    if (P.second > done) {
      cout << P.second << " " << P.first << "\n";
      done = P.first;
    }
  }
}
