#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000;
const int maxn = 5010;
long long a[maxn];
long long last[maxn];
int dp[maxn];
long long s[maxn];
int n;
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  fill(last, last + maxn, INF);
  fill(dp, dp + maxn, maxn);
  s[0] = 0;
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  dp[0] = 0;
  last[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      if (s[i] - s[j] >= last[j]) {
        if (dp[i] >= dp[j] + i - j - 1) {
          dp[i] = dp[j] + i - j - 1;
          last[i] = min(last[i], s[i] - s[j]);
        }
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}
