#include <bits/stdc++.h>
const double eps = 1e-9;
using namespace std;
int l, r, ans, inf, s, n, a[5555], ss[5555], f[5555][5555], m;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ss[i] = ss[i - 1] + a[i];
  }
  memset(f, 63, sizeof(f));
  inf = f[0][0];
  ans = inf;
  f[2][1] = 0;
  for (int i = 2; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (f[i][j] != inf) {
        f[i + 1][j + 1] = min(f[i + 1][j + 1], f[i][j] + 1);
        s = ss[i - 1] - ss[i - j - 1];
        l = i;
        r = n;
        while (r > l) {
          m = (l + r) / 2;
          if (ss[m] - ss[i - 1] >= s)
            r = m;
          else
            l = m + 1;
        }
        if (ss[r] - ss[i - 1] >= s)
          f[i + (r - i + 1)][r - i + 1] =
              min(f[i + (r - i + 1)][r - i + 1], f[i][j] + r - i);
      }
  for (int j = 0; j <= n + 2; j++) ans = min(ans, f[n + 1][j]);
  cout << (ans) << endl;
  return 0;
}
