#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const int inf = (1 << 31) - 1;
const int mod = 1000000007;
int dp[5050][5050];
int n;
int dat[5050];
int sum[5050];
int main() {
  scanf("%d", &n);
  memset(sum, 0, sizeof(sum));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &dat[i]);
    sum[i] = sum[i - 1] + dat[i];
  }
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++) dp[i][j] = inf;
  for (int i = 1; i <= n; i++) dp[i][1] = sum[i];
  for (int i = 1; i < n; i++) {
    for (int j = n; j > 0; j--) dp[i][j] = min(dp[i][j], dp[i][j + 1]);
    for (int j = n; j > i; j--) {
      int s = sum[j] - sum[i];
      int l = 1, r = i;
      int pos = -1;
      int mid;
      while (l <= r) {
        mid = (l + r) >> 1;
        if (dp[i][mid] == inf)
          r = mid - 1;
        else if (dp[i][mid] <= s) {
          pos = mid;
          l = mid + 1;
        } else
          r = mid - 1;
      }
      if (pos != -1) dp[j][pos + 1] = min(dp[j][pos + 1], s);
    }
  }
  for (int i = n; i > 0; i--)
    if (dp[n][i] < inf) {
      printf("%d\n", n - i);
      return 0;
    }
}
