You are on page 1of 1

#include <iostream>

#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;


int main(int argc, char *argv[])
{
vector <long long> str;
long long time,sum=0,num,i=0,j=0;
// Put your code below
while(1){
cin>>time;
if(time==0)break;
while(time--){
cin>>num;
str.push_back(num);
}
sum=str[0];
if(sum<0)sum*=-1;
while(1){
str[j+1]=str[j]+str[j+1];
//cout<<"m="<<str[j+1]<<endl;
if(str[j+1]<0){
i=str[j+1]*-1;
sum+=i;
}
else sum+=str[j+1];
j++;
if(j==str.size()-1)break;
}
cout<<sum<<endl;
str.clear();
sum=0;
j=0;
i=0;
}
return 0;
}

You might also like