#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long, vector<pair<long long, long long> > > b;
  for (int i = 0; i < n; i++) {
    long long x = 0;
    for (int j = i; j >= 0; j--) {
      x += a[j];
      b[x].push_back(make_pair(j, i));
    }
  }
  vector<pair<long long, long long> > ans;
  long long r = -1;
  map<long long, vector<pair<long long, long long> > >::iterator it;
  for (it = b.begin(); it != b.end(); it++) {
    vector<pair<long long, long long> > temp;
    r = -1;
    for (int i = 0; i < it->second.size(); i++) {
      if (it->second[i].first > r) {
        temp.push_back(it->second[i]);
        r = it->second[i].second;
      }
    }
    if (temp.size() > ans.size()) ans = temp;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  return 0;
}
