Created
January 18, 2014 15:44
-
-
Save KT-Yeh/8492141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cmath> | |
using namespace std; | |
int a[100001]; | |
int main() | |
{ | |
int n; | |
while(scanf("%d",&n)){ | |
if (n==0) break; | |
for(int i=0;i<n;i++) | |
scanf("%d",&a[i]); | |
long long int ans=0; | |
for(int i=0;i<n-1;i++){ | |
ans += abs(a[i]); | |
a[i+1] += a[i]; | |
} | |
printf("%lld\n",ans); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment