#include <bits/stdc++.h>
const long long maxn = 1e6 + 5;
const long long mod = 1e9 + 7;
const long long base = 1331;
using namespace std;
map<long long, vector<pair<long long, long long>>> m;
long long a[maxn];
long long n;
void read(void) {
  cin >> n;
  for (long long i = 1; i <= (long long)(n); ++i) cin >> a[i];
  for (long long i = 1; i <= (long long)(n); ++i) {
    long long sum = 0;
    for (long long j = (long long)(i); j >= (long long)(1); --j) {
      sum += a[j];
      m[sum].push_back({j, i});
    }
  }
  vector<pair<long long, long long>> ans;
  for (auto &p : m) {
    vector<pair<long long, long long>> d = p.second;
    long long pivot = -1;
    vector<pair<long long, long long>> tmp;
    for (auto x : d) {
      if (x.first > pivot) {
        pivot = x.second;
        tmp.push_back({x.first, x.second});
      }
    }
    if (tmp.size() > ans.size()) ans = tmp;
  }
  cout << ans.size() << '\n';
  for (auto &x : ans) cout << x.first << ' ' << x.second << '\n';
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read();
}
