#pragma comment(linker, "/stack:640000000")
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI=acos(-1.0);
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define MP(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define rep(i,n) for(int i = 1 ; i<=(n) ; i++)
#define repI(i,n) for(int i = 0 ; i<(n) ; i++)
#define FOR(i,L,R) for (int i = (int)(L); i <= (int)(R); i++)
#define ROF(i,L,R) for (int i = (int)(L); i >= (int)(R); i--)
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define ALL(p) p.begin(),p.end()
#define ALLR(p) p.rbegin(),p.rend()
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define getC(n) scanf("%c",&n)
#define getF(n) scanf("%lf",&n)
#define getS(n) scanf("%s",n)
#define bitCheck(N,in) ((bool)(N&(1<<(in))))
#define bitOff(N,in) (N&(~(1<<(in))))
#define bitOn(N,in) (N|(1<<(in)))
#define bitFlip(a,k) (a^(1<<(k)))
#define bitCount(a) __builtin_popcount(a)
#define bitCountLL(a) __builtin_popcountll(a)
#define bitLeftMost(a) (63-__builtin_clzll((a)))
#define bitRightMost(a) (__builtin_ctzll(a))
#define iseq(a,b) (fabs(a-b)<EPS)
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define vi vector < int >
#define vii vector < vector < int > >
#define pii pair< int, int >
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
#ifdef dipta007
#define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(args...) /// Just strip off all debug tokens
#define trace(...) ///yeeeee
#endif
struct debugger{
template<typename T> debugger& operator , (const T& v){
cerr<<v<<" ";
return *this;
}
}dbg;
///****************** template ends here ****************
int t,n,m;
#define mx 100004
int arr[mx];
struct info
{
int sum;
int prop;
}tree[mx*4];
info call(info a,info b)
{
info tmp;
tmp.sum = min(a.sum, b.sum);
tmp.prop = 0;
///merge two info
return tmp;
}
void init(int node,int b,int e)
{
if(b==e)
{
tree[node].sum = arr[b];
tree[node].prop = 0;
///do something
return;
}
int Left=node<<1;
int Right=(node<<1)+1;
int mid=(b+e)>>1;
init(Left,b,mid);
init(Right,mid+1,e);
tree[node]=call(tree[Left],tree[Right]);
}
void propagate(int node,int b,int e)
{
if(b==e)
{
tree[node].prop=0;
return;
}
int Left=node<<1;
int Right=(node<<1)+1;
int mid=(b+e)>>1;
///update propagation
int prop = tree[node].prop;
tree[Left].prop += tree[node].prop;
tree[Right].prop += tree[node].prop;
tree[node].prop=0;
///update tree[left].sum
// tree[Left].sum += tree[node].prop;
tree[Left].sum += prop;
///update tree[right].sum
// tree[Right].sum += tree[node].prop;
tree[Right].sum += prop;
}
int query(int node,int b,int e,int i,int j) ///range i theke j
{
if (i > e || j < b)return INF;
if(tree[node].prop)propagate(node,b,e);
if(b>=i && e<=j)
{
///do something
return tree[node].sum;
}
int Left=node<<1;
int Right=(node<<1)+1;
int mid=(b+e)>>1;
int p1 = query(Left,b,mid,i,j);
int p2 = query(Right,mid+1,e,i,j);
return min(p1,p2);
}
void update(int node,int b,int e,int i,int j, int newVal)
{
if(tree[node].prop)propagate(node,b,e);
if (i > e || j < b) return;
if (b >= i && e <= j)
{
tree[node].sum += newVal;
tree[node].prop += (newVal);
///do something
return;
}
int Left=node<<1;
int Right=(node<<1)+1;
int mid=(b+e)>>1;
update(Left,b,mid,i,j,newVal);
update(Right,mid+1,e,i,j,newVal);
tree[node]=call(tree[Left],tree[Right]);
}
int main() {
#ifdef dipta007
//READ("in.txt");
// WRITE("out.txt");
#endif // dipta007
// ios_base::sync_with_stdio(0);cin.tie(0);
int n;
getI(n);
// int res= 0;
// int cnt = 0;
FOR(i,1,n)
{
getI(arr[i]);
}
init(1,1,n);
int cnt = 0;
int i = 1;
while(i <= n)
{
int low = i, high = n;
int res = -1;
while(low <= high)
{
int mid = (low + high) / 2;
if(query(1,1,n, i, mid) <= 0)
{
high = mid - 1;
}
else
{
res = mid;
low = mid + 1;
}
}
if(res==-1)
{
i++;
debug("*")
continue;
}
cnt++;
int kk = query(1,1,n, i, res);
update(1,1,n,i,res,-kk);
debug(i, res, kk, query(1,1,n, i, res))
}
printf("%d\n",cnt);
return 0;
}
I3ByYWdtYSBjb21tZW50KGxpbmtlciwgIi9zdGFjazo2NDAwMDAwMDAiKQojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGRvdWJsZSBFUFMgPSAxZS05Owpjb25zdCBpbnQgSU5GID0gMHg3ZjdmN2Y3ZjsKY29uc3QgZG91YmxlIFBJPWFjb3MoLTEuMCk7CgojZGVmaW5lICAgIFJFQUQoZikgCSAgICAgICAgIGZyZW9wZW4oZiwgInIiLCBzdGRpbikKI2RlZmluZSAgICBXUklURShmKSAgIAkgICAgIGZyZW9wZW4oZiwgInciLCBzdGRvdXQpCiNkZWZpbmUgICAgTVAoeCwgeSkgCSAgICAgbWFrZV9wYWlyKHgsIHkpCiNkZWZpbmUgICAgUEIoeCkgICAgICAgICAgICAgcHVzaF9iYWNrKHgpCiNkZWZpbmUgICAgcmVwKGksbikgICAgICAgICAgZm9yKGludCBpID0gMSA7IGk8PShuKSA7IGkrKykKI2RlZmluZSAgICByZXBJKGksbikgICAgICAgICBmb3IoaW50IGkgPSAwIDsgaTwobikgOyBpKyspCiNkZWZpbmUgICAgRk9SKGksTCxSKSAJICAgICBmb3IgKGludCBpID0gKGludCkoTCk7IGkgPD0gKGludCkoUik7IGkrKykKI2RlZmluZSAgICBST0YoaSxMLFIpIAkgICAgIGZvciAoaW50IGkgPSAoaW50KShMKTsgaSA+PSAoaW50KShSKTsgaS0tKQojZGVmaW5lICAgIEZPUkVBQ0goaSx0KSAgICAgIGZvciAodHlwZW9mKHQuYmVnaW4oKSkgaT10LmJlZ2luKCk7IGkhPXQuZW5kKCk7IGkrKykKI2RlZmluZSAgICBBTEwocCkgCSAgICAgICAgIHAuYmVnaW4oKSxwLmVuZCgpCiNkZWZpbmUgICAgQUxMUihwKSAJICAgICAgICAgcC5yYmVnaW4oKSxwLnJlbmQoKQojZGVmaW5lICAgIFNFVChwKSAJICAgICAgICAgbWVtc2V0KHAsIC0xLCBzaXplb2YocCkpCiNkZWZpbmUgICAgQ0xSKHApICAgICAgICAgICAgbWVtc2V0KHAsIDAsIHNpemVvZihwKSkKI2RlZmluZSAgICBNRU0ocCwgdikgICAgICAgICBtZW1zZXQocCwgdiwgc2l6ZW9mKHApKQojZGVmaW5lICAgIGdldEkoYSkgCSAgICAgICAgIHNjYW5mKCIlZCIsICZhKQojZGVmaW5lICAgIGdldElJKGEsYikgCSAgICAgc2NhbmYoIiVkJWQiLCAmYSwgJmIpCiN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WYWwpOwogICAgICAgIC8vL2RvIHNvbWV0aGluZwoJCXJldHVybjsKCX0KCWludCBMZWZ0PW5vZGU8PDE7CglpbnQgUmlnaHQ9KG5vZGU8PDEpKzE7CglpbnQgbWlkPShiK2UpPj4xOwoJdXBkYXRlKExlZnQsYixtaWQsaSxqLG5ld1ZhbCk7Cgl1cGRhdGUoUmlnaHQsbWlkKzEsZSxpLGosbmV3VmFsKTsKCXRyZWVbbm9kZV09Y2FsbCh0cmVlW0xlZnRdLHRyZWVbUmlnaHRdKTsKfQoKCgppbnQgbWFpbigpIHsKICAgICNpZmRlZiBkaXB0YTAwNwogICAgICAgIC8vUkVBRCgiaW4udHh0Iik7Ci8vICAgICAgICBXUklURSgib3V0LnR4dCIpOwogICAgI2VuZGlmIC8vIGRpcHRhMDA3Ci8vICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7Y2luLnRpZSgwKTsKCiAgICBpbnQgbjsKICAgIGdldEkobik7CgovLyAgICBpbnQgcmVzPSAgMDsKLy8gICAgaW50IGNudCA9IDA7CiAgICBGT1IoaSwxLG4pCiAgICB7CiAgICAgICAgZ2V0SShhcnJbaV0pOwogICAgfQogICAgaW5pdCgxLDEsbik7CgogICAgaW50IGNudCA9IDA7CiAgICBpbnQgaSA9IDE7CiAgICB3aGlsZShpIDw9IG4pCiAgICB7CiAgICAgICAgaW50IGxvdyA9IGksIGhpZ2ggPSBuOwogICAgICAgIGludCByZXMgPSAtMTsKICAgICAgICB3aGlsZShsb3cgPD0gaGlnaCkKICAgICAgICB7CiAgICAgICAgICAgIGludCBtaWQgPSAobG93ICsgaGlnaCkgLyAyOwogICAgICAgICAgICBpZihxdWVyeSgxLDEsbiwgaSwgbWlkKSA8PSAwKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBoaWdoID0gbWlkIC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHJlcyA9IG1pZDsKICAgICAgICAgICAgICAgIGxvdyA9IG1pZCArIDE7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYocmVzPT0tMSkKICAgICAgICB7CiAgICAgICAgICAgIGkrKzsKICAgICAgICAgICAgZGVidWcoIioiKQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY250Kys7CiAgICAgICAgaW50IGtrID0gcXVlcnkoMSwxLG4sIGksIHJlcyk7CiAgICAgICAgdXBkYXRlKDEsMSxuLGkscmVzLC1rayk7CiAgICAgICAgZGVidWcoaSwgcmVzLCBraywgcXVlcnkoMSwxLG4sIGksIHJlcykpCiAgICB9CgoKCiAgICBwcmludGYoIiVkXG4iLGNudCk7CgoKICAgIHJldHVybiAwOwp9Cg==