#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k;
  cin >> n;
  int a[n];
  unordered_map<int, vector<pair<int, int> > > m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    k = 0;
    for (j = i; j >= 0; j--) {
      k += a[j];
      m[k].push_back({i + 1, j + 1});
    }
  }
  unordered_map<int, vector<pair<int, int> > >::iterator it;
  vector<pair<int, int> > temp, ans;
  for (it = m.begin(); it != m.end(); it++) {
    temp.push_back({it->second[0].second, it->second[0].first});
    for (i = 1; i < it->second.size(); i++) {
      if (it->second[i].second > temp.back().second)
        temp.push_back({it->second[i].second, it->second[i].first});
    }
    if (temp.size() > ans.size()) ans = temp;
    temp.clear();
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
