RT, 代码:
#include<bits/stdc++.h>
using namespace std;
long long n, a[100005], sum;
bool f;
void Solve(){
while(cin >> n){
if(n == 0){
return ;
}
if(!f){
f = true;
}
else{
cout << endl;
}
long long ans = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
sum += a[i];
ans += abs(sum);
}
cout << ans;
}
}
int main(){
Solve();
return 0;
}