#include <bits/stdc++.h>
using namespace std;
map<int, vector<pair<int, int> > > M;
int a[2000], dp[1550][1550] = {0}, Y[1550];
pair<int, int> Ans[1550];
set<int> v;
bool cmp(pair<int, int> a, pair<int, int> b) {
  return (a.first == b.first ? a.second < b.second : a.first < b.first);
}
int find_ans(int index) {
  int ans = 0, xx, yy;
  sort(M[index].begin(), M[index].end(), cmp);
  xx = M[index][0].first;
  yy = 0;
  for (int i = 0; i < M[index].size(); i++) {
    int x = M[index][i].first;
    int y = M[index][i].second;
    if (x > yy) {
      ans++;
      xx = x;
      yy = y;
    } else if (y < yy) {
      yy = y;
      xx = x;
    }
  }
  return ans;
}
void print(int index) {
  int ans = 0, xx, yy;
  sort(M[index].begin(), M[index].end(), cmp);
  xx = M[index][0].first;
  yy = 0;
  for (int i = 0; i < M[index].size(); i++) {
    int x = M[index][i].first;
    int y = M[index][i].second;
    if (x > yy) {
      ans++;
      xx = x;
      yy = y;
      Y[x] = y;
      Ans[ans] = make_pair(x, y);
    } else if (y < yy) {
      yy = y;
      xx = x;
      Ans[ans] = make_pair(x, y);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  int n, in;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 1; j--) {
      dp[j][i] = dp[j + 1][i] + a[j];
      int k = dp[j][i];
      M[k].push_back(make_pair(j, i));
      v.insert(k);
    }
  }
  int ans = 0;
  set<int>::iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    int val = find_ans(*it);
    if (val > ans) in = *it, ans = val;
  }
  cout << ans << endl;
  print(in);
  for (int i = 1; i <= ans; i++)
    cout << Ans[i].first << " " << Ans[i].second << endl;
}
