#include <bits/stdc++.h>
using namespace std;
int dp[5005][5005];
long long a[5005];
long long b[5005];
int dt[5005][5005];
const int INF = (1 << 28);
int main() {
  int n;
  scanf("%d", &n);
  int i;
  b[0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    b[i] = b[i - 1] + a[i];
  }
  for (i = 0; i <= n + 1; i++) {
    int j;
    for (j = 0; j <= n + 1; j++) {
      dp[i][j] = INF;
      dt[i][j] = INF;
    }
  }
  dt[0][0] = 0;
  dp[0][0] = 0;
  for (i = 1; i <= n; i++) {
    int j;
    for (j = 1; j <= i; j++) {
      int l = 1;
      int r = j - 1;
      while (l < r) {
        int mid = (l + r) / 2;
        if (b[i] - b[j - 1] >= b[j - 1] - b[mid - 1])
          r = mid;
        else
          l = mid + 1;
      }
      if (b[i] - b[j - 1] >= b[j - 1] - b[r - 1])
        dp[i][j] = dt[j - 1][r] + i - j;
    }
    dp[i][0] = i;
    for (j = i; j >= 0; j--) dt[i][j] = min(dt[i][j + 1], dp[i][j]);
  }
  printf("%d\n", dt[n][0]);
}
