#include <bits/stdc++.h>
using namespace std;
const int MAX = 1500 * 1500 + 6;
const long long MOD = 1e9 + 7;
vector<pair<int, int>> segs[MAX];
int a[1506];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<pair<int, pair<int, int>>> v;
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = i; j <= n; j++) {
      sum += a[j];
      v.push_back({sum, {i, j}});
    }
  }
  sort(v.begin(), v.end());
  int cur = 1, cur_sum = v[0].first;
  for (auto x : v) {
    if (x.first != cur_sum) {
      cur++;
      cur_sum = x.first;
    }
    segs[cur].push_back(x.second);
  }
  vector<pair<int, int>> ans;
  int k = 0;
  for (int i = 1; i <= cur; i++) {
    sort(segs[i].begin(), segs[i].end());
    int R = 0;
    vector<pair<int, int>> cur;
    for (pair<int, int> x : segs[i]) {
      if (x.first > R) {
        cur.push_back(x);
        R = x.second;
        continue;
      }
      if (x.second < R) {
        cur.pop_back();
        cur.push_back(x);
        R = x.second;
      }
    }
    int cur_k = cur.size();
    if (cur_k > k) {
      k = cur_k;
      ans = cur;
    }
  }
  cout << k << "\n";
  for (pair<int, int> x : ans) {
    cout << x.first << " " << x.second << "\n";
  }
}
