#include <bits/stdc++.h>
int n, a[5055], s[5055];
int read() {
  register char ch = getchar();
  register int ret = 0;
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret;
}
int f[5055], tot, g[5055];
int main() {
  scanf("%d", &n);
  for (register int i = (1); i <= (n); ++i) {
    a[i] = read();
    s[i] = s[i - 1] + a[i];
  }
  memset(f, 0x3f, sizeof f);
  f[0] = 0;
  for (register int i = (1); i <= (n); ++i) {
    for (register int j = (i - 1); j >= (0); --j)
      if (f[j] <= s[i] - s[j]) {
        f[i] = s[i] - s[j];
        g[i] = g[j] + i - j - 1;
        break;
      }
  }
  printf("%d", g[n]);
  return 0;
}
