#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int h[N + 5];
long long sum[N + 5];
int f[N + 5][N + 5], p[N + 5], g[N + 5][N + 5];
int Find(int x, int k) {
  int l = 0, r = p[k], mid;
  if (g[k][r] == x) --r;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    int y = g[k][mid];
    if (sum[x] >= sum[y] + f[y][k])
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
    sum[i] = sum[i - 1] + h[i];
  }
  memset(f, 0x3f, sizeof(f));
  for (int i = 1; i <= n; ++i) f[i][1] = sum[i];
  for (int i = 1; i <= n; ++i) {
    g[1][++p[1]] = i;
    for (int j = 2; j <= i; ++j) {
      int k = Find(i, j - 1);
      if (k) {
        f[i][j] = sum[i] - sum[g[j - 1][k]];
        int kk = g[j][p[j]];
        while (p[j] && sum[kk] + f[kk][j] >= sum[i] + f[i][j])
          --p[j], kk = g[j][p[j]];
        g[j][++p[j]] = i;
      }
    }
  }
  int flg = 0;
  for (int i = n; i >= 1; --i) {
    if (f[n][i] != 0x3f3f3f3f) {
      flg = i;
      break;
    }
  }
  cout << n - flg << '\n';
  return 0;
}
