#include <bits/stdc++.h>
using namespace std;
const int N = 500001;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
using namespace std;
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int min(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
long long int inf = 100000000000000000;
vector<int> adj[N];
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  map<int, vector<pair<int, int> > > segs;
  for (int r = 0; r < n; r++) {
    int sum = 0;
    for (int l = r; l >= 0; l--) {
      sum += a[l];
      segs[sum].push_back(make_pair(l, r));
    }
  }
  int result = 0;
  vector<pair<int, int> > best;
  for (auto p : segs) {
    vector<pair<int, int> >& pp = p.second;
    int cur = 0;
    int r = -1;
    vector<pair<int, int> > now;
    for (auto seg : pp)
      if (seg.first > r) {
        cur++;
        now.push_back(seg);
        r = seg.second;
      }
    if (cur > result) {
      result = cur;
      best = now;
    }
  }
  cout << result << '\n';
  for (auto seg : best) cout << seg.first + 1 << " " << seg.second + 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  int t = 0;
  while (t++ < T) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
