#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, i;
int A[5005], dp[5005], dp2[5005][5005];
int f(int x, int y) {
  if (x >= n) return 0;
  int &r = dp2[x][y];
  if (r) return r;
  r = f(x + 1, y + 1) + 1;
  int q = lower_bound(dp + x + 1, dp + n + 1, 2 * dp[x] - dp[x - y]) - dp;
  r = min(r, f(q, q - x) + q - x - 1);
  return r;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", A + i);
    dp[i] = dp[i - 1] + A[i];
  }
  cout << f(1, 1);
}
