#include <bits/stdc++.h>
using namespace std;
int S[5005], F[5005][5005];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    int a;
    scanf("%d", &a);
    S[i] = S[i - 1] + a;
    F[i][1] = 1;
    int k = 0;
    for (int j = 1; j < i; ++j) {
      int c = 2 * S[j] - S[i];
      while (S[k] < c) ++k;
      if (k + 1 > j || F[j][k + 1] == INT_MIN)
        F[i][j + 1] = INT_MIN;
      else
        F[i][j + 1] = 1 + F[j][k + 1];
    }
    for (int j = i - 1; j >= 1; --j) F[i][j] = max(F[i][j], F[i][j + 1]);
  }
  printf("%d\n", N - F[N][1]);
}
