#include <bits/stdc++.h>
using namespace std;
int solve(vector<long long> v, int n, int sum) {
  if (n == 0) return 0;
  if (n == 0 && sum)
    return max(solve(v, n - 1, sum), solve(v, n - 1, sum + v[n - 1]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(6);
  long long t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> v(n + 5);
    for (long long i = 0; i <= n - 1; i++) cin >> v[i];
    unordered_map<int, vector<pair<long long, long long> > > h;
    int sum = 0;
    int ans = 0;
    int index;
    for (int i = 0; i < n; i++) {
      sum = 0;
      for (int j = i; j >= 0; j--) {
        sum += v[j];
        if (h.find(sum) == h.end() || h[sum].back().second < j + 1) {
          h[sum].emplace_back(j + 1, i + 1);
        }
        if ((int)h[sum].size() > ans) {
          index = sum;
          ans = h[sum].size();
        }
      }
    }
    cout << ans << "\n";
    for (auto i : h[index]) {
      cout << i.first << " " << i.second << "\n";
    }
  }
}
