#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, pos = 0;
cin >> n;
vector<ll> a(n + 1), val(n + 1);
vector<int> cnt(n + 1), first(n + 1, 1e9);
first[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] += a[i - 1];
if (a[i] - a[first[cnt[i - 1]]] >= val[first[cnt[i - 1]]]) {
pos = first[cnt[i - 1]];
}
for (int j = pos; j < i; j++) {
if (a[i] - a[j] < val[j]) {
break;
}
cnt[i] = cnt[j] + 1;
val[i] = a[i] - a[j];
pos = j;
}
first[cnt[i]] = min(i, first[cnt[i]]);
}
cout << cnt[n];
return 0;
}