#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5010;
int sum[MAXN];
int F[MAXN][MAXN];
int N;
int tknp(int l, int r, int val) {
  int dau = l, cuoi = r, mid, res = -1;
  int tg = 0;
  while (dau <= cuoi) {
    mid = (dau + cuoi) >> 1;
    tg = sum[r] - sum[mid - 1];
    if (tg <= val) {
      res = r - mid + 1;
      cuoi = mid - 1;
    } else
      dau = mid + 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  sum[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> sum[i];
    sum[i] += sum[i - 1];
  }
  for (int i = 1; i <= N; i++)
    for (int j = 0; j <= N; j++) F[i][j] = 0;
  for (int i = 1; i <= N; i++) F[i][0] = -1;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i - 1; j++) {
      int vt = tknp(1, i - j, sum[i] - sum[i - j]);
      int cur = -1;
      if (vt != -1 && F[i - j][vt] != -1) {
        cur = F[i - j][vt] + 1;
      }
      F[i][j] = max(cur, F[i][j - 1]);
    }
    F[i][i] = max(1, F[i][i - 1]);
  }
  cout << N - F[N][N];
}
