#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int TAM = 5555;
int h[TAM], n;
int acc[TAM];
int mem[TAM][TAM];
int bs(int from, int to, int val) {
  int L = from + 1, R = to, mid;
  while (L < R) {
    mid = (L + R) / 2;
    if (acc[mid] - acc[from] >= val)
      R = mid;
    else
      L = mid + 1;
  }
  if (R == to) return -1;
  return R;
}
int main() {
  scanf("%d", &n);
  memset(mem, -1, sizeof(mem));
  for (int i = 0; i < n; i++) scanf("%d", &h[i]);
  acc[0] = mem[1][0] = h[0];
  for (int i = 1; i < n; i++) mem[1][i] = acc[i] = h[i] + acc[i - 1];
  for (int ntowers = 1; ntowers <= n; ntowers++) {
    for (int taken = 0; taken < n; taken++) {
      if (mem[ntowers][taken] == -1) {
        if (taken == 0 || mem[ntowers][taken - 1] == -1) continue;
        mem[ntowers][taken] = mem[ntowers][taken - 1] + h[taken];
      }
      if (taken && mem[ntowers][taken - 1] != -1)
        mem[ntowers][taken] =
            min(mem[ntowers][taken - 1] + h[taken], mem[ntowers][taken]);
      int npos = bs(taken, n, mem[ntowers][taken]);
      if (npos == -1) continue;
      int d = acc[npos];
      d -= acc[taken];
      int nv = max(mem[ntowers][taken], d);
      if (mem[ntowers + 1][npos] == -1 || mem[ntowers + 1][npos] > nv)
        mem[ntowers + 1][npos] = nv;
    }
  }
  int ans = -1;
  for (int i = n; i > 0 && ans == -1; i--)
    if (mem[i][n - 1] != -1) ans = n - i;
  printf("%d\n", ans);
  return 0;
}
