#include <bits/stdc++.h>
using namespace std;
map<int, vector<pair<int, int> > > mp;
int n, tt;
int arr[300000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int r = 1; r <= n; r++) {
    long long sum = 0;
    for (int l = r; l >= 1; l--) {
      sum += arr[l];
      mp[sum].push_back(make_pair(l, r));
    }
  }
  map<int, vector<pair<int, int> > >::iterator it;
  vector<pair<int, int> > ans;
  for (it = mp.begin(); it != mp.end(); it++) {
    int sum = 0;
    vector<pair<int, int> > &now = it->second;
    vector<pair<int, int> > cnt;
    int r = -1;
    for (int i = 0; i < now.size(); i++) {
      if (now[i].first > r)
        sum++, r = now[i].second,
               cnt.push_back(make_pair(now[i].first, now[i].second));
    }
    if (sum > tt) ans = cnt, tt = sum;
  }
  cout << tt << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
