#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0;
  cin >> n;
  vector<int> a(n);
  map<int, vector<pair<int, int> > > av;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int sum = 0;
    for (int j = i; j >= 0; j--) {
      sum += a[j];
      av[sum].push_back(make_pair(i, j));
    }
  }
  vector<pair<int, int> > ans;
  for (auto& cs : av) {
    sort((cs.second).begin(), (cs.second).end());
    int last = -1;
    vector<pair<int, int> > cur;
    for (auto& p : cs.second) {
      if (p.second > last) {
        last = p.first;
        cur.push_back(p);
      }
    }
    if (cur.size() > ans.size()) ans = cur;
  }
  cout << ans.size() << endl;
  for (auto& x : ans) cout << x.second + 1 << ' ' << x.first + 1 << endl;
  return 0;
}
