#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5, inf = 1 << 30;
inline long long read() {
  register long long f = 1, sum = 0;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    sum = (sum << 1) + (sum << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f * sum;
}
int n;
int l[N], s[N], dp[N];
signed main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + read();
    dp[i] = l[i] = inf;
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = 0; j <= i; j++) {
      if (s[i] - s[j] >= l[j] && dp[i] >= dp[j] + i - j - 1) {
        dp[i] = dp[j] + i - j - 1;
        l[i] = min(l[i], s[i] - s[j]);
      }
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
