#include <bits/stdc++.h>
using namespace std;
long long modpow(long long base, long long exp, long long modulus) {
  base %= modulus;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
long long n;
long long a[100005];
long long dp[5004][5005];
long long bin(long long lo, long long hi, long long val) {
  long long ans = -1;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (a[mid] >= val) {
      ans = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  return ans;
}
long long doit(long long prev, long long curr, int flag) {
  if (curr == n + 1) return 0;
  if (dp[prev][curr] != -1) return dp[prev][curr];
  long long ans = 0;
  long long y = 100009;
  long long x = 1 + doit(prev, curr + 1, flag);
  long long val = a[curr - 1] - a[prev - 1] + a[curr - 1];
  long long ind = bin(curr, n, val);
  if (ind != -1) {
    y = doit(curr, ind + 1, flag) + (ind - curr);
  }
  ans = min(x, y);
  dp[prev][curr] = ans;
  return ans;
}
int main() {
  scanf("%lld", &n);
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] = a[i] + a[i - 1];
  }
  long long ans = doit(1, 2, 0);
  cout << ans;
  printf("\n");
  ;
  return 0;
}
