#include <bits/stdc++.h>
using namespace std;
constexpr int MAX_N = 5000;
constexpr int INF = numeric_limits<int>::max();
int N;
int H[MAX_N + 1];
int DP[MAX_N + 1][MAX_N + 1];
void print(int* ptr, int n) {
  printf("[ ");
  while (n > 0) {
    printf("%d ", *ptr);
    ++ptr;
    --n;
  }
  printf("]\n");
}
int main() {
  cin >> N;
  if (N < 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  DP[0][0] = H[0];
  for (int i = 1; i < N; i++) {
    if (DP[0][i - 1] == -1) {
      DP[0][i] = -1;
    } else {
      DP[0][i] = (H[i] >= H[i - 1]) ? H[i] : -1;
    }
  }
  if (DP[0][N - 1] != -1) {
    cout << 0 << endl;
    return 0;
  }
  for (int n = 1; n < N; n++) {
    DP[n][0] = H[0];
    for (int i = 1; i < N; i++) {
      DP[n][i] = INF;
      if (DP[n - 1][i] != -1) {
        DP[n][i] = min(DP[n][i], DP[n - 1][i]);
      }
      if (DP[n][i - 1] != -1 && DP[n][i - 1] <= H[i]) {
        DP[n][i] = min(DP[n][i], H[i]);
      }
      if (DP[n - 1][i - 1] != -1) {
        DP[n][i] = min(DP[n][i], H[i] + DP[n - 1][i - 1]);
      }
      int S = H[i];
      for (int m = n - 1; m >= 0; m--) {
        int j = i - (n - m);
        S += H[j];
        if (j < 0 || (j > 0 && DP[m][j - 1] == -1)) break;
        if ((j == 0) || S >= DP[m][j - 1]) {
          DP[n][i] = min(DP[n][i], S);
          break;
        }
      }
    }
    for (int j = 1; j < N; j++) {
      DP[n][j] = (DP[n][j] == INF) ? -1 : DP[n][j];
    }
    if (DP[n][N - 1] != -1) {
      cout << n << endl;
      return 0;
    }
  }
  return 0;
}
