#include <bits/stdc++.h>
int dp[5010], sum[5010], last[5010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    sum[i] = sum[i - 1] + a;
    dp[i] = last[i] = 1 << 30;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      if (sum[i] - sum[j] >= last[j] && dp[i] >= dp[j] + i - j - 1) {
        dp[i] = dp[j] + i - j - 1;
        if (last[i] > sum[i] - sum[j]) last[i] = sum[i] - sum[j];
      }
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
