#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
const int mod = 1e9 + 7;
const long long inf = 1e18;
map<int, int> mp;
vector<pair<int, int> > ans, tmp[N];
int num[1505], tot;
int main() {
  int n;
  scanf("%d", &n);
  int maxn = 0, pos = 0;
  for (int i = 1; i <= n; i++)
    scanf("%d", &num[i]), num[i] = num[i - 1] + num[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 1; j--) {
      int tp = num[i] - num[j - 1];
      if (!mp[tp]) mp[tp] = ++tot;
      int sz = tmp[mp[tp]].size();
      if (!sz)
        tmp[mp[tp]].push_back(make_pair(j, i));
      else if (tmp[mp[tp]][sz - 1].second < j)
        tmp[mp[tp]].push_back(make_pair(j, i));
      if (tmp[mp[tp]].size() > maxn) {
        maxn = tmp[mp[tp]].size();
        pos = mp[tp];
      }
    }
  }
  ans = tmp[pos];
  printf("%d\n", maxn);
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
