#include <bits/stdc++.h>
using namespace std;
int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const int maxn = 5e3 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9 + 10;
int dp[maxn][maxn], a[maxn];
vector<pair<int, int> > vc[maxn];
int32_t main() {
  int n = in();
  for (int i = 0; i < n; i++) a[i] = in();
  memset(dp, 63, sizeof dp);
  dp[0][1] = a[0];
  vc[0].push_back({a[0], 1});
  for (int i = 1; i < n; i++) {
    int sum = 0;
    int id = 0;
    for (int j = i; j >= 0; j--) {
      sum += a[j];
      if (j == 0) {
        dp[i][1] = sum;
      } else {
        int id = vc[j - 1][0].first <= sum ? 0 : -1;
        if (id != -1)
          dp[i][1 + vc[j - 1][id].second] =
              min(sum, dp[i][1 + vc[j - 1][id].second]);
      }
    }
    for (int j = i + 1; j >= 1; j--) {
      if (dp[i][j] >= inf) continue;
      vc[i].push_back({dp[i][j], j});
    }
  }
  for (int cnt = n; cnt >= 1; cnt--) {
    if (dp[n - 1][cnt] < inf) return cout << n - cnt << endl, 0;
  }
}
