#include <bits/stdc++.h>
using namespace std;
const int N = 1500 * 1500 + 5;
map<int, vector<pair<int, int>>> maping;
int Next[N];
int mark[N];
int dp[N];
int arr[1505];
int range[1505];
int size, test;
int solve(int idx1) {
  if (idx1 >= size) return 0;
  if (mark[idx1] == test) return dp[idx1];
  mark[idx1] = test;
  return dp[idx1] = max(solve(idx1 + 1), solve(Next[idx1]) + 1);
}
void output(int idx1, int idx2) {
  if (idx1 >= size) return;
  if (solve(idx1 + 1) >= solve(Next[idx1]) + 1) {
    output(idx1 + 1, idx2);
  } else {
    cout << maping[idx2][idx1].first << ' ' << maping[idx2][idx1].second
         << '\n';
    output(Next[idx1], idx2);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    int cur = 0;
    for (int j = i; j <= n; j++) {
      cur += arr[j];
      maping[cur].push_back({i, j});
    }
  }
  test = 0;
  int Max = -1, idx = -1;
  for (auto &cur : maping) {
    test++;
    vector<pair<int, int>> &vec = cur.second;
    sort(vec.begin(), vec.end());
    size = vec.size();
    if (size <= Max) continue;
    memset(range, -1, sizeof range);
    for (int i = size - 1; i >= 0; i--) {
      int st = vec[i].first;
      if (range[st - 1] == -1)
        range[st - 1] = i;
      else
        range[st - 1] = min(range[st - 1], i);
    }
    for (int i = 1500; i >= 1; i--) {
      if (range[i] == -1) range[i] = size + 5;
      if (i < 1500) range[i] = min(range[i], range[i + 1]);
    }
    for (int i = 0; i < size; i++) Next[i] = range[vec[i].second];
    int sol = solve(0);
    if (sol > Max) {
      Max = sol;
      idx = cur.first;
    }
  }
  cout << Max << '\n';
  vector<pair<int, int>> &vec = maping[idx];
  size = vec.size();
  memset(range, -1, sizeof range);
  for (int i = size - 1; i >= 0; i--) {
    int st = vec[i].first;
    if (range[st - 1] == -1)
      range[st - 1] = i;
    else
      range[st - 1] = min(range[st - 1], i);
  }
  for (int i = 1500; i >= 1; i--) {
    if (range[i] == -1) range[i] = size + 5;
    if (i < 1500) range[i] = min(range[i], range[i + 1]);
  }
  for (int i = 0; i < size; i++) {
    Next[i] = range[vec[i].second];
  }
  test++;
  output(0, idx);
  return 0;
}
