#include <bits/stdc++.h>
using namespace std;
int n, a[5005], dp[5005], b[5005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    int p = i, s = a[i];
    while (p > 0 && s < b[p - 1]) {
      s += a[p - 1];
      p--;
    }
    dp[i] = dp[p - 1] + i - p;
    b[i] = s;
  }
  printf("%d\n", dp[n]);
  return 0;
}
