#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
int n, h[MAXN], dp[MAXN][2];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> h[i];
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i][1] = 1000000000;
    int sum = 0;
    for (int j = i; j >= 1; j--) {
      sum += h[j];
      if (dp[j - 1][0] <= sum) {
        if (dp[j - 1][1] + (i - j) < dp[i][1]) {
          dp[i][0] = sum;
          dp[i][1] = dp[j - 1][1] + (i - j);
        }
      }
    }
  }
  cout << dp[n][1] << endl;
  return 0;
}
