#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 5e3 + 10;
long long dp[MAXN][MAXN];
long long a[MAXN];
long long e[MAXN];
long long d[MAXN];
long long u[MAXN];
long long p[MAXN];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[1][1] = 1;
  e[1] = 1;
  u[1] = 1;
  p[1] = a[1];
  for (long long i = 2; i <= n; i++) {
    for (long long j = i; j >= 1; j--) {
      d[j - 1] += a[i];
      while (u[j - 1] > 1 && p[j - 1] + a[u[j - 1] - 1] <= d[j - 1]) {
        e[j - 1] = max(e[j - 1], dp[j - 1][u[j - 1] - 1]);
        p[j - 1] += a[u[j - 1] - 1];
        u[j - 1]--;
      }
      if (d[j - 1] < a[j - 1] || e[j - 1] == -1) {
        dp[i][j] = -1;
      } else {
        dp[i][j] = e[j - 1] + 1;
      }
    }
    e[i] = dp[i][i];
    p[i] = a[i];
    u[i] = i;
  }
  long long res = 0;
  for (long long i = 1; i <= n; i++) {
    res = max(res, dp[n][i]);
  }
  cout << n - res;
}
