#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long ret = 0, f = 1;
  char x = getchar();
  while (!(x >= '0' && x <= '9')) {
    if (x == '-') f = -1;
    x = getchar();
  }
  while (x >= '0' && x <= '9') ret = ret * 10 + x - '0', x = getchar();
  return ret * f;
}
char get_char() {
  char x = getchar();
  while (!((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'))) x = getchar();
  return x;
}
const int L_N = 5e3 + 10;
const int INF = 1e9 + 10;
int f[L_N][L_N], h[L_N], sum[L_N];
int N;
int SUM(int i, int j) { return sum[j] - sum[i - 1]; }
int REM(int times, int i, int j) { return times - (j - i); }
int main() {
  N = read();
  for (int i = (1); i <= (N); i++) h[i] = read();
  for (int i = (1); i <= (N); i++)
    for (int j = (0); j <= (N); j++) f[i][j] = INF;
  for (int i = (1); i <= (N); i++) sum[i] = sum[i - 1] + h[i];
  int times = 0, k = 1;
  for (int i = (1); i <= (N); i++) {
    bool ok = false;
    while (!ok) {
      for (int tk = (i); tk >= (1); tk--) {
        int rem = REM(times, tk, i);
        if (rem < 0) break;
        if (rem >= 0 && SUM(tk, i) >= f[tk - 1][rem]) {
          ok = true;
          k = tk;
          break;
        }
      }
      if (!ok) times++;
    }
    int tk = k;
    for (int j = (times); j <= (i - 1); j++) {
      while (true) {
        int rem = REM(j, tk + 1, i);
        if (tk < i && SUM(tk + 1, i) >= f[tk][rem])
          tk++;
        else
          break;
      }
      f[i][j] = SUM(tk, i);
    }
    for (int j = (i); j <= (N); j++) f[i][j] = f[i][i - 1];
  }
  printf("%d\n", times);
  return 0;
}
