// Born_To_Laugh - Hughie Do
#include <bits/stdc++.h>
#define alle(AC) AC.begin(), AC.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
[[maybe_unused]] const int MOD = 998244353, INF = 1e9 + 7;
#define int ll
const int maxn = 5e5 + 10;
int n, a[maxn];
ll pref[maxn];
ll dp[maxn], last[maxn];
vector<pair<int, int>> st;
void solve(){
cin >> n;
for(int i=1; i<=n; ++i) cin >> a[i];
for(int i=1; i<=n; ++i) pref[i] = pref[i - 1] + a[i];
for(int i=1; i<=n; ++i){
while(!st.empty() && st.back().se >= last[i - 1] + pref[i - 1]){
st.pop_back();
}
st.push_back({i - 1, last[i - 1] + pref[i - 1]});
int lo = 0, hi = st.size() - 1, res = lo;
while(hi >= lo){
int mid = (lo + hi) >> 1;
if(st[mid].se <= pref[i]){
lo = mid + 1;
res = mid;
}
else hi = mid - 1;
}
int j = st[res].fi;
dp[i] = dp[j] + 1;
last[i] = pref[i] - pref[j];
// cout << i << ' ' << j << ' ' << dp[i] << '\n';
}
cout << dp[n] << '\n';
}
signed main(){
// freopen("inp.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}