#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010;
long long dp[maxn][maxn], a[maxn], sum[maxn];
int main() {
  memset(dp, 0x3f, sizeof(dp));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%I64d", &a[i]), sum[i] = sum[i - 1] + a[i];
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = 0;
  for (int i = 1; i < n; i++) {
    long long sum2 = 0;
    int p = i + 1;
    for (int j = i; j >= 1; j--) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
      while (p <= n && sum2 < sum[i] - sum[j - 1]) {
        sum2 += a[p];
        p++;
      }
      if (sum2 >= sum[i] - sum[j - 1]) {
        dp[p - 1][i + 1] = min(dp[p - 1][i + 1], dp[i][j] + p - 1 - (i + 1));
      }
    }
  }
  long long ans = 1e18;
  for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
