#include <bits/stdc++.h>
using namespace std;
int main() {
  long long h[5050], dp[5050], l[5050], n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", h + i);
    long long j = i - 1, cur = h[i];
    while (j && cur < l[j]) cur += h[j--];
    dp[i] = j ? dp[j] + i - j - 1 : i - 1;
    l[i] = cur;
  }
  printf("%lld\n", dp[n]);
  return 0;
}
