#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000;
const int INF = 1e9;
int N;
int H[MAXN + 10], sum[MAXN + 10];
int dp[MAXN + 10][MAXN + 10];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &H[i]);
  }
  partial_sum(H + 1, H + N + 1, sum + 1);
  for (int i = N; i >= 1; i--) {
    int l = N + 1;
    int mn = INF;
    for (int j = 1; j < i; j++) {
      while (l > i && sum[l - 1] >= 2 * sum[i - 1] - sum[j - 1]) {
        l--;
        mn = min(mn, l + dp[l + 1][i]);
      }
      dp[i][j] = min(INF, -i + mn);
    }
  }
  int res = N - 1;
  for (int r = 1; r < N; r++) {
    res = min(res, r - 1 + dp[r + 1][1]);
  }
  printf("%d\n", res);
}
