#include <bits/stdc++.h>
using namespace std;
int n;
int a[5010];
int s[5010];
int memo[5010][5010];
int solve(int in, int pre) {
  if (in == n) return 0;
  if (in > n) return 1e9 + 1;
  if (memo[in][pre] != -1) return memo[in][pre];
  int curheight = s[in] - s[pre - 1];
  int cur = solve(in + 1, pre) + 1;
  int x = lower_bound(s + 1, s + n + 1, curheight + s[in]) - s;
  cur = min(cur, solve(x, in + 1) + (x - in - 1));
  return memo[in][pre] = cur;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  memset(memo, -1, sizeof(memo));
  cout << solve(1, 1);
}
