#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
int solve() {
  map<int, vector<pair<int, int> > > m;
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  for (int i = 1; i < n + 1; i++) {
    int sum = 0;
    for (int j = i; j > 0; j--) {
      sum += a[j];
      if (m[sum].empty() || m[sum].back().second < j) {
        m[sum].push_back(make_pair(j, i));
      }
    }
  }
  vector<pair<int, int> > ans;
  for (auto it : m) {
    if (it.second.size() > ans.size()) ans = it.second;
  }
  printf("%d\n", ans.size());
  for (auto it : ans) printf("%d %d\n", it.first, it.second);
  return 0;
}
int main() {
  int t = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  clock_t time_req;
  time_req = clock();
  while (t--) {
    solve();
  }
  time_req = clock() - time_req;
  return 0;
}
