#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, vector<pair<int, int>>> mp;
  for (int i = 0; i < n; i++) {
    long long int sum = 0;
    for (int j = i; j >= 0; j--) {
      sum += a[j];
      if (mp.find(sum) == mp.end())
        mp[sum].push_back({j, i});
      else {
        if (mp[sum].back().second < j) mp[sum].push_back({j, i});
      }
    }
  }
  vector<pair<int, int>> ans;
  int mx = 0;
  for (auto it : mp) {
    if (it.second.size() > mx) {
      mx = it.second.size();
      ans = it.second;
    }
  }
  cout << mx << "\n";
  for (auto it : ans) {
    cout << it.first + 1 << " " << it.second + 1 << "\n";
  }
}
