#include <bits/stdc++.h>
using namespace std;
namespace FGF {
int n;
const int N = 5005;
int dp[N], l[N], sum[N];
void work() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), sum[i] = sum[i - 1] + x;
  memset(dp, 0x3f, sizeof(dp)), memset(l, 0x3f, sizeof(l));
  dp[0] = l[0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i - 1; j >= 0; j--)
      if (sum[i] - sum[j] >= l[j]) {
        dp[i] = dp[j] + i - j - 1, l[i] = sum[i] - sum[j];
        break;
      }
  printf("%d\n", dp[n]);
}
}  // namespace FGF
int main() {
  FGF::work();
  return 0;
}
