#include <bits/stdc++.h>
using namespace std;
const int maxn = 5004;
int h[maxn], n, sumh[maxn];
int T[maxn][maxn], dp[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &h[i]);
    sumh[i] = sumh[i - 1] + h[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n + n + 1; ++j) T[i][j] = -(1 << 30);
  }
  T[1][1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = i; j >= 2; --j) {
      int sum = sumh[i] - sumh[j - 1];
      if (sum < h[j - 1]) continue;
      int le = 0, ri = j - 1;
      while (ri - le > 1) {
        int mid = (le + ri) >> 1;
        if (sumh[j - 1] - sumh[mid - 1] > sum)
          le = mid;
        else
          ri = mid;
      }
      T[i][j] = max(T[i][j + 1], 1 + T[j - 1][ri]);
    }
    T[i][1] = max(1, T[i][2]);
  }
  cout << n - T[n][1] << endl;
  return 0;
}
