#include <bits/stdc++.h>
using namespace std;
int n, h[5000], s[5000], dp[5000], res[5000];
int main() {
  scanf("%d%d", &n, h);
  dp[0] = s[0] = h[0];
  for (int i = 1; i < n; ++i) {
    scanf("%d", h + i);
    s[i] = s[i - 1] + h[i];
  }
  for (int i = 1; i < n; ++i) {
    dp[i] = s[i];
    res[i] = i;
    for (int j = 0; j < i; ++j) {
      if (dp[j] <= s[i] - s[j] && s[i] - s[j] < dp[i]) {
        dp[i] = s[i] - s[j];
        res[i] = res[j] + i - j - 1;
      }
    }
  }
  printf("%d\n", res[n - 1]);
}
