#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1000010];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,wz=0,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		wz+=a[i];
		if(wz<0){
			cnt+=abs(wz);
			wz=0;
		}
	}
	cout<<cnt;
	return 0;
}

0 条评论

目前还没有评论...

信息

ID
116
时间
1000ms
内存
256MiB
难度
8
标签
递交数
56
已通过
9
上传者