#if defined(_USE_PCH_)
#include "pch.hpp"
#else
#include <bits/stdc++.h>
#endif
#define RNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_<=V_##_END; V_++)
#define IRNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_>=V_##_END; V_--)
#ifdef _WIN32
#define long int64_t
#endif
#define fir first
#define sec second
#define _UN using namespace
using namespace std;
typedef pair<int,int> pii;
typedef __int128 i128;
const int MAXN=2e5+10; const int INF=0x3f3f3f3f;
int n,ans=INF; long A[MAXN];
void case1(){
    long x=0; int c=0;
    RNG(i,1,n){
        x+=A[i];
        if(x<0) return;
        c+=A[i]>0;
    }
    if(x==0) ans=c;
}
struct Treap{
#define ls (T[u].ls_)
#define rs (T[u].rs_)
#define mid ((l+r)/2)
    struct Tt{ int ls_,rs_; long val,sum; int siz; unsigned pri; } T[MAXN*10]; int nnd; mt19937 rng;
    void pushup(int u){
        T[u].sum=T[u].val+!!ls*T[ls].sum+!!rs*T[rs].sum;
        T[u].siz=1       +!!ls*T[ls].siz+!!rs*T[rs].siz;
    }
    pii split1(int u,long x){
        if(!u) return {0,0};
        if(T[u].val>=x){
            auto [v,w]=split1(rs,x);
            rs=v; pushup(u);
            return {u,w};
        }else{
            auto [v,w]=split1(ls,x);
            ls=w; pushup(u);
            return {v,u};
        }
    }
    pii split2(int u,long x){
        if(!u) return {0,0};
        if(x<T[ls].sum+T[u].val){
            auto [v,w]=split2(ls,x);
            ls=w; pushup(u);
            return {v,u};
        }else{
            auto [v,w]=split2(rs,x-T[ls].sum-T[u].val);
            rs=v; pushup(u);
            return {u,w};
        }
    }
    int merge(int u,int v){
        if(!u||!v) return u|v;
        if(T[u].pri>T[v].pri){
            rs=merge(rs,v);
            pushup(u);
            return u;
        }else{
            T[v].ls_=merge(u,T[v].ls_);
            pushup(v);
            return v;
        }
    }
    int rt;
    void ins(long x){
        auto [u,v]=split1(rt,x);
        auto w=++nnd; T[w]={0,0,x,x,1,unsigned(rng())};
        rt=merge(merge(u,w),v);
    }
    Tt del(long x){
        assert(x<=T[rt].sum);
        auto [u,v]=split2(rt,x);
        rt=v;
        return T[u];
    }
    long getmn(int u){
        while(ls) u=ls;
        return T[u].val;
    }
    template<typename TFn> void walk(int u,TFn fn){
        if(ls) walk(ls,fn);
        fn(u);
        if(rs) walk(rs,fn);
    }
#undef ls
#undef rs
#undef mid
} trp;
int main(){
#if defined(_LOCAL_)
    freopen("in","r",stdin);
//  freopen("out","w",stdout);
//  freopen("/dev/null","w",stderr);
#else
//  freopen("k.in","r",stdin);
//  freopen("k.out","w",stdout);
#endif
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
    cin>>n;
    RNG(i,1,n) cin>>A[i];
    IRNG(i,n,1) A[i]-=A[i-1];
    case1();
    long a=0,s=0; int c=0;
    RNG(i,1,n){
        if(A[i]>=0) trp.ins(A[i]);
        else{ s+=-A[i]; auto x=trp.del(s-a); a+=x.sum,c+=x.siz; }
        {
            cerr<<i<<" "<<A[i]<<" "<<s<<" "<<a<<"\n";
            long x=a; int j=c;
            cerr<<j<<" "<<x<<"\n";
            trp.walk(trp.rt,[&x,&j](int u){
                j++,x+=trp.T[u].val;
                cerr<<j<<" "<<x<<"\n";
            });
            cerr<<"\n";
        }
    }
    ans=min(ans,c+1);
    cout<<ans<<"\n";
}