#include <bits/stdc++.h>
using namespace std;
const int N = 5005, INF = 0x3f3f3f3f;
int n, h[N], s[N], f[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + h[i], f[i] = h[i] = INF;
  for (int i = 1; i <= n; i++) {
    for (int j = i - 1; j >= 0; j--)
      if (f[i] > f[j] + i - j - 1 && s[i] - s[j] >= h[j]) {
        f[i] = f[j] + i - j - 1;
        h[i] = s[i] - s[j];
      } else if (f[i] == f[j] + i - j - 1 && s[i] - s[j] >= h[j]) {
        h[i] = min(h[i], s[i] - s[j]);
      }
  }
  cout << f[n] << endl;
  return 0;
}
