#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long double EPS = 1e-9;
void pre() {}
int s[5020], f[5020], g[5020];
void solve() {
  int n;
  cin >> n;
  for (long long int i = 0; i < n; ++i) {
    cin >> s[i + 1];
    s[i + 1] += s[i];
  }
  for (long long int i = 1; i <= n; ++i) {
    int j = i - 1;
    while (s[i] - s[j] < g[j]) j--;
    f[i] = f[j] + i - j - 1;
    g[i] = s[i] - s[j];
  }
  cout << f[n] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pre();
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
}
