#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long mod = 998244353;
const int phash = 3;
const long long modhash = 1000000000000000003;
map<int, vector<pair<int, int> > > d;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int r = 1; r <= n; r++) {
    int sum = 0;
    for (int l = r; l >= 1; l--) {
      sum += a[l];
      d[sum].push_back({l, r});
    }
  }
  vector<pair<int, int> > ans;
  for (auto it : d) {
    vector<pair<int, int> > now;
    auto seg = it.second;
    int r = -1;
    for (auto it2 : seg) {
      if (it2.first > r) {
        now.push_back(it2);
        r = it2.second;
      }
    }
    if (ans.size() < now.size()) ans = now;
  }
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i.first << " " << i.second << '\n';
}
