#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
unordered_map<int, pair<int, int>> par[N];
unordered_map<int, int> dp[N];
int n, a[N], ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    par[i] = par[i - 1];
    for (int j = 0; j < i; j++)
      if (dp[i][a[i] - a[j]] < dp[j][a[i] - a[j]] + 1) {
        dp[i][a[i] - a[j]] = dp[j][a[i] - a[j]] + 1;
        par[i][a[i] - a[j]] = {i, j};
        if (dp[i][ans] < dp[i][a[i] - a[j]]) ans = a[i] - a[j];
      }
  }
  cout << dp[n][ans] << endl;
  for (int i = n; i; i = par[i][ans].second)
    if (par[i][ans].first)
      cout << par[i][ans].second + 1 << ' ' << par[i][ans].first << endl;
}
