#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
struct edge {
  int from;
  int to;
  int w;
};
int comp(const edge& f, const edge& l) {
  if (f.from < l.from)
    return 1;
  else if (f.from > l.from)
    return 0;
  else {
    if (f.w > l.w) return 1;
  }
  return 0;
}
map<int, vector<edge> > d;
int check_cnt(int sum) {
  sort(d[sum].begin(), d[sum].end(), comp);
  set<pair<int, int> > wait;
  int cnt = 0;
  for (edge it : d[sum]) {
    if (it.w == 1)
      wait.insert({it.from, it.to});
    else {
      if (wait.count({it.to, it.from})) {
        cnt++;
        wait.clear();
      }
    }
  }
  return cnt;
}
void make(int sum) {
  sort(d[sum].begin(), d[sum].end(), comp);
  set<pair<int, int> > wait;
  for (edge& it : d[sum]) {
    if (it.w == 1)
      wait.insert({it.from, it.to});
    else {
      if (wait.count({it.to, it.from})) {
        cout << it.to + 1 << " " << it.from + 1 << "\n";
        wait.clear();
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> p(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[i + 1] = p[i] + a[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      sum = p[j + 1] - p[i];
      d[sum].push_back((edge){i, j, 1});
      d[sum].push_back((edge){j, i, -1});
    }
  }
  int max_val = 0, max_cnt = 0, cnt = 0;
  for (auto& it : d) {
    cnt = check_cnt(it.first);
    if (max_cnt < cnt) {
      max_cnt = cnt;
      max_val = it.first;
    }
  }
  cout << max_cnt << "\n";
  make(max_val);
  return 0;
}
