#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
const int MOD = 1e9 + 7;
int n, arr[N], nex[N][N], dp[N][N];
int solve(int i, int last) {
  if (nex[last][i] == n + 1) return n - i;
  if (dp[i][last] != -1) return dp[i][last];
  int ret = 1e9;
  ret = min(ret, solve(i + 1, last) + 1);
  ret = min(ret, solve(nex[last][i], i + 1) + nex[last][i] - i - 1);
  return dp[i][last] = ret;
}
int main() {
  scanf("%d", &n);
  for (int a = 1; a <= n; a++) scanf("%d", &arr[a]);
  for (int a = 1; a <= n; a++) {
    int x = arr[a];
    int y = arr[a];
    int idx = a;
    while (idx <= n && y - x < x) y += arr[++idx];
    nex[a][a] = idx;
    for (int b = a + 1; b <= n; b++) {
      x += arr[b];
      while (idx <= n && y - x < x) y += arr[++idx];
      nex[a][b] = idx;
    }
  }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", solve(1, 1));
  return 0;
}
