#include <bits/stdc++.h>
using namespace std;
int n, ans, a[1510];
map<int, map<int, int>> p;
vector<pair<int, int>> v;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
  for (int i = (1); i <= (n); ++i) {
    int x = 0;
    for (int j = (i); j <= (n); ++j) {
      x += a[j];
      if (p[x].count(i))
        p[x][i] = min(p[x][i], j);
      else
        p[x][i] = j;
    }
  }
  for (auto s : p) {
    pair<int, int> t = {0, 0};
    int w = 0;
    vector<pair<int, int>> vi;
    for (auto i : s.second) {
      if (i.first > t.second) {
        if (t.second) vi.push_back(t);
        ++w;
        t = i;
      } else if (i.second < t.second)
        t = i;
    }
    vi.push_back(t);
    if (w > ans) ans = w, v = vi;
  }
  printf("%d\n", ans);
  for (auto i : v) printf("%d %d\n", i.first, i.second);
}
