#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
const long long M = 1505;
const long long mod = 1000000007;
const long long inf = (1 << 30);
const long long linf = (1LL << 61);
int n, v[M], x, nr, l[M * M];
vector<pair<long long, long long> > a, ans;
map<int, vector<pair<long long, long long> > > mp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> v[i], v[i] += v[i - 1];
  for (int j = 1; j <= n; ++j) {
    for (int i = 1; i <= j; ++i) {
      x = v[j] - v[i - 1];
      if (mp[x].size() == 0) l[++nr] = x;
      mp[x].push_back({i, j});
    }
  }
  for (int i = 1; i <= nr; ++i) {
    a.resize(0);
    for (int j = 0; j < mp[l[i]].size(); ++j) {
      if (!a.size() || a[a.size() - 1].second < mp[l[i]][j].first)
        a.push_back(mp[l[i]][j]);
    }
    if (a.size() > ans.size()) ans = a;
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); ++i)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  return 0;
}
