#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int dp[N][N], v[N];
int n;
int f(int s, int e) {
  if (s) return v[e] - v[s - 1];
  return v[e];
}
int solve(int s = 0, int e = 0) {
  if (e == n - 1) return 0;
  int &ret = dp[s][e];
  if (~ret) return ret;
  ret = solve(s, e + 1) + 1;
  int sum = f(s, e);
  int j = lower_bound(v + e + 1, v + n, sum + v[e]) - v;
  if (j == n) return ret;
  ret = min(ret, solve(e + 1, j) + j - e - 1);
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    if (i) v[i] += v[i - 1];
  }
  memset(dp, -1, sizeof dp);
  cout << solve() << endl;
  return 0;
}
