#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int r = power(a, b / 2) % 1000000007;
  if (b % 2 == 0)
    return (r * r) % 1000000007;
  else
    return (((r * r) % 1000000007) * a) % 1000000007;
}
int prime[1000009];
void sieve(int n) {
  prime[0] = prime[1] = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (!prime[i]) {
      for (int j = 2 * i; j <= n; j++) {
        prime[j]++;
      }
    }
  }
}
bool comp(const pair<long long int, long long int> &a,
          const pair<long long int, long long int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  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];
      mp[sum].push_back({j, i});
    }
  }
  int res = 0;
  vector<pair<int, int>> best;
  for (auto it : mp) {
    vector<pair<int, int>> pp = it.second;
    int c = 0;
    int r = -1;
    vector<pair<int, int>> v;
    for (auto it1 : pp) {
      if (it1.first > r) {
        c++;
        v.push_back(it1);
        r = it1.second;
      }
      if (c > res) {
        res = c;
        best = v;
      }
    }
  }
  cout << res << "\n";
  for (auto it : best) {
    cout << it.first + 1 << " " << it.second + 1 << "\n";
  }
  return 0;
}
