#include <bits/stdc++.h>
int height[5001], dp[5001], mh[5001];
int getmin(int a, int b) {
  if (a < b) return a;
  return b;
}
int main() {
  int sum, n, i, j, k;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &height[i]);
      dp[i] = 5001;
      mh[i] = 5001;
    }
    height[0] = 0;
    dp[1] = dp[0] = 0;
    mh[0] = 0;
    mh[1] = height[1];
    for (i = 2; i <= n; i++) {
      sum = 0;
      for (j = i; j > 0; j--) {
        sum += height[j];
        if (sum >= mh[j - 1]) {
          if (dp[j - 1] + i - j < dp[i]) {
            dp[i] = dp[j - 1] + i - j;
            mh[i] = sum;
          }
        }
      }
    }
    printf("%d\n", dp[n]);
  }
}
