#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  map<long long, vector<pair<long long, long long> > > mp;
  for (long long i = 0; i < n; ++i) {
    long long sum = 0;
    for (long long j = i; j >= 0; --j) {
      sum += a[j];
      mp[sum].push_back(make_pair(j, i));
    }
  }
  long long ans = 0;
  vector<pair<long long, long long> > v;
  for (auto &it : mp) {
    vector<pair<long long, long long> > p = it.second;
    long long cur = 0, r = -1;
    vector<pair<long long, long long> > temp;
    for (auto &i : p) {
      if (i.first > r) {
        cur++;
        temp.push_back(i);
        r = i.second;
      }
    }
    if (cur > ans) {
      v = temp;
      ans = cur;
    }
  }
  cout << ans << '\n';
  for (pair<long long, long long> i : v)
    cout << i.first + 1 << " " << i.second + 1 << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  t = 1;
  while (t--) solve();
}
