#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
int n, a[N], pre[N], dp[N][N];
int solve(int l, int r) {
  if (l > n || r > n) return dp[l][r] = 1;
  if (dp[l][r] != -1) return dp[l][r];
  int ans = solve(l, r + 1), sum = pre[r] - pre[l - 1];
  int up = upper_bound(pre + 1, pre + n + 1, sum + pre[r] - 1) - pre;
  if (up != n + 1 && up > r) ans = max(ans, 1 + solve(r + 1, up));
  return dp[l][r] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << n - solve(1, 1) << '\n';
  return 0;
}
