#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 1;
const int INF = 1e9 + 7;
const long double EPS = 1e-7;
long long h[maxn];
int dp[5002][5002];
long long pref[5002];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; ++j) dp[i][j] = INF;
  dp[1][1] = 0;
  for (int r = 1; r < n; ++r) {
    int x = r + 1;
    long long height_left = 0;
    long long height_right = h[x];
    for (int l = r; l >= 1; --l) {
      dp[l][r + 1] = min(dp[l][r + 1], dp[l][r] + 1);
      height_left += h[l];
      while (x < n && height_left > height_right) {
        ++x;
        height_right += h[x];
      }
      if (height_left <= height_right)
        dp[r + 1][x] = min(dp[r + 1][x], dp[l][r] + (x - r - 1));
    }
  }
  int ans = INF;
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, dp[i][n]);
  }
  cout << ans;
}
