#include <bits/stdc++.h>
using namespace std;
int sum[5010], f[5010][5010], a[5010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      f[i][j] = 100000000;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int k = i - 1, minf = (i == 1 ? 0 : 100000000);
    for (int j = i; j <= n; ++j) {
      while (k && sum[i - 1] - sum[k - 1] <= sum[j] - sum[i - 1]) {
        minf = min(minf, f[k][i - 1]);
        --k;
      }
      f[i][j] = minf + j - i;
    }
  }
  int ans = 100000000;
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, f[i][n]);
  }
  cout << ans << endl;
  return 0;
}
