#include <bits/stdc++.h>
using namespace std;
int n, a[5005], s[5005], f[5005];
int read() {
  int res = 0, op = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') op = -1;
    ch = getchar();
  }
  while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
  return res * op;
}
void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  if (n < 3) {
    if (n == 2)
      puts(a[1] <= a[2] ? "0" : "1");
    else
      puts("0");
    return 0;
  }
  s[1] = a[1];
  for (int i = 2; i <= n; i++) {
    int sum = a[i], j;
    for (j = i - 1; j >= 1 && sum < s[j]; j--) sum += a[j];
    s[i] = sum;
    f[i] = f[j] + i - j - 1;
  }
  printf("%d", f[n]);
  return 0;
}
