#include <bits/stdc++.h>
using namespace std;
int dp[5050][5050];
int midp[5050][5050];
int n;
int a[5050];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i++ < n;) cin >> a[i];
  dp[0][0] = 0;
  memset(midp[0], 0, sizeof(midp[0]));
  for (int i = 0; i++ < n;) {
    long long h = a[i - 1], th = a[i];
    int l = i - 1, r = i - 1;
    for (; r >= 0; --r) {
      while (l > 0 and h + a[l - 1] <= th) {
        --l;
        h += a[l];
      }
      if (h > th)
        dp[i][i - r] = 5050;
      else
        dp[i][i - r] = midp[r][min(r, r - l + 1)] + (i - r - 1);
      h -= a[r];
      th += a[r];
    }
    midp[i][0] = 5050;
    for (int f = 0; f++ < i;) midp[i][f] = min(midp[i][f - 1], dp[i][f]);
  }
  cout << midp[n][n];
  return 0;
}
