#include <bits/stdc++.h>
using namespace std;
int n, h[5005], dp[5005], s[5005], ml[5005];
int read() {
  int x = 0, fl = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fl = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * fl;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    h[i] = read();
    s[i] = s[i - 1] + h[i];
  }
  memset(dp, 0x3f, sizeof(dp));
  memset(ml, 0x3f, sizeof(ml));
  dp[0] = ml[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (ml[j - 1] <= s[i] - s[j - 1]) {
        ml[i] = min(ml[i], s[i] - s[j - 1]);
        dp[i] = min(dp[i], dp[j - 1] + i - j);
      }
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
