#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5010;
int ht[MAXN], sumht[MAXN], dp[MAXN][MAXN];
vector<pair<int, int> > nexti, tni;
int n;
int main() {
  scanf("%d", &n);
  memset(sumht, 0, sizeof sumht);
  for (int i = 1; i <= (int)(n); i++) {
    scanf("%d", &ht[i]);
    sumht[i] = sumht[i - 1] + ht[i];
  }
  for (int i = 0; i < (int)(MAXN); i++)
    for (int j = 0; j < (int)(MAXN); j++) dp[i][j] = 2000000000;
  for (int j = 1; j <= n; j++) {
    int previ = -1;
    int k = 0;
    for (int i = j; i <= n; i++) {
      if (j == 1) {
        dp[i][j] = sumht[i];
      } else {
        while (k < nexti.size() && nexti[k].first <= i) {
          previ = max(previ, nexti[k].second);
          k++;
        }
        if (previ >= 0) dp[i][j] = sumht[i] - sumht[previ];
      }
      if (dp[i][j] == 2000000000) continue;
      int lo = i + 1;
      int hi = n;
      while (lo < hi) {
        int mid = (lo + hi) >> 1;
        if (sumht[mid] - sumht[i] < dp[i][j]) {
          lo = mid + 1;
        } else {
          hi = mid;
        }
      }
      if (sumht[lo] - sumht[i] >= dp[i][j]) tni.push_back(make_pair(lo, i));
    }
    nexti = tni;
    sort(nexti.begin(), nexti.end());
    tni.clear();
  }
  for (int j = n; j >= 1; j--) {
    if (dp[n][j] < 2000000000) {
      printf("%d\n", n - j);
      return 0;
    }
  }
  return 0;
}
