#include <bits/stdc++.h>
using namespace std;
int n, a[5007], px[5007];
int f[5007], len[5007];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    px[i] = px[i - 1] + a[i];
  }
  int pre = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = pre; j < i; j++) {
      if (f[i] <= f[j] + 1 && px[i] - px[j] >= len[j]) {
        f[i] = f[j] + 1;
        pre = j;
        len[i] = px[i] - px[j];
      }
    }
  }
  printf("%d\n", n - f[n]);
}
