#include <bits/stdc++.h>
using namespace std;
const int MX = 1e9;
int n, pf[5001] = {}, dp[5001][5001] = {}, cp[5001] = {};
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    pq[5001];
inline int qry(int l, int r) { return pf[r] - pf[l - 1]; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    pf[i] = pf[i - 1] + a;
  }
  for (int i = 1; i <= n; i++) {
    cp[i] = -MX;
  }
  cp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      dp[i][j] = -MX;
      while (!pq[i - 1 - j].empty()) {
        if (pq[i - 1 - j].top().first <= i) {
          cp[i - 1 - j] = max(cp[i - 1 - j], pq[i - 1 - j].top().second);
          pq[i - 1 - j].pop();
        } else {
          break;
        }
      }
      if (cp[(i - 1 - j)] >= 0) {
        dp[i][j] = pf[i] - pf[cp[(i - 1 - j)]];
        int k = lower_bound(pf, pf + n + 1, dp[i][j] + pf[i]) - pf;
        pq[i - j].push({k, i});
      }
    }
  }
  int rs = 0;
  for (int j = 0; j < n; j++) {
    if (dp[n][j] > 0) {
      rs = j;
      break;
    }
  }
  cout << rs << "\n";
  return 0;
}
