#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 1e9;
const long long llf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int n;
int a[1510];
map<int, int> is;
int d[2251000];
int len = 0;
int ans;
vector<pair<int, int> > f[2251000];
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    int ret = 0;
    for (int j = i; j <= n; j++) {
      ret += a[j];
      if (!is[ret]) {
        d[++len] = ret;
        is[ret] = len;
      }
      f[is[ret]].push_back(pair<int, int>(i, j));
    }
  }
  vector<pair<int, int> > res;
  for (int i = 1; i <= len; i++) {
    sort(f[i].begin(), f[i].end(), cmp);
    int dr = 0, ret = 0;
    vector<pair<int, int> > p;
    for (int j = 0; j < f[i].size(); j++) {
      pair<int, int> x = f[i][j];
      if (x.first > dr) {
        dr = x.second;
        p.push_back(x);
        ret++;
      }
    }
    if (ret > ans) {
      ans = ret;
      res = p;
    }
  }
  cout << ans << endl;
  for (pair<int, int> x : res) cout << x.first << " " << x.second << endl;
  return 0;
}
