#include <bits/stdc++.h>
int f[5005], g[5005], h[5005], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  memset(f, 66, sizeof(f));
  f[0] = 0;
  for (int i = 1; i <= n; i++) {
    int j = i, sum = h[j];
    while (j && sum < f[j - 1]) sum += h[--j];
    if (sum >= f[j - 1]) f[i] = sum, g[i] = g[j - 1] + i - j;
  }
  printf("%d\n", g[n]);
  return 0;
}
