#include <bits/stdc++.h>
using namespace std;
const int max_n = 5001;
int dp[max_n][max_n];
int a[max_n];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  memset(dp, 127, sizeof(dp));
  const int inf = dp[0][0];
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int k = i;
    int* dpl = dp[i];
    for (int j = 1; j < i; j++) {
      dpl[j] = min(dpl[j - 1], dpl[j]);
    }
    for (int j = i, cur = 0; j < n; j++) {
      cur += a[j];
      while (k > 0 && dpl[k - 1] <= cur) {
        k--;
      }
      if (dpl[k] <= cur) {
        dp[j + 1][k + j - i] = min(dp[j + 1][k + j - i], cur);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (dp[n][i] != inf) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
