#include <bits/stdc++.h>
using namespace std;
void show(vector<long long> &v) {
  for (long long &x : v) cout << x << " ";
  cout << endl;
}
void ext(long long a) {
  cout << a;
  std::exit(0);
}
const long long e9 = (long long)1e9;
const long long e6 = (long long)1e6;
const long long e5 = (long long)1e5;
long long n;
vector<long long> v;
vector<long long> pref;
bool cmp(pair<long long, long long> &a, pair<long long, long long> &b) {
  return a.second < b.second;
}
vector<pair<long long, long long>> calc(vector<pair<long long, long long>> &x) {
  vector<pair<long long, long long>> ret;
  sort((x).begin(), (x).end(), cmp);
  long long last = -100000000000000000LL;
  for (auto &a : x) {
    if (a.first > last) {
      last = a.second;
      ret.push_back(a);
    }
  }
  return ret;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  v.resize(1 + n);
  pref.resize(1 + n);
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    pref[i] = v[i] + pref[i - 1];
  }
  vector<pair<long long, long long>> ans;
  map<long long, vector<pair<long long, long long>>> dp;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i - 1; j >= 0; j--) {
      long long sm = pref[i] - pref[j];
      dp[sm].push_back(make_pair(j + 1, i));
    }
  }
  for (auto &x : dp) {
    vector<pair<long long, long long>> r = calc(x.second);
    if (r.size() > ans.size()) ans = r;
  }
  cout << ans.size() << endl;
  for (auto &x : ans) cout << x.first << " " << x.second << endl;
  return 0;
}
