#include<stdio.h>
int main() {
int c,n,i,t,max,sum;
scanf("%d",&c);
while(c--){
scanf("%d",&n);
max=sum=0;
while(n--){
scanf("%d",&t);
sum+=t;
if(sum<0) sum=0;
else if(sum>max) max=sum;
}
printf("%d\n",max);
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4gIAppbnQgbWFpbigpIHsKCWludCBjLG4saSx0LG1heCxzdW07CglzY2FuZigiJWQiLCZjKTsKCXdoaWxlKGMtLSl7CgkJc2NhbmYoIiVkIiwmbik7CgkJbWF4PXN1bT0wOwoJCXdoaWxlKG4tLSl7CgkJCXNjYW5mKCIlZCIsJnQpOwoJCQlzdW0rPXQ7CgkJCWlmKHN1bTwwKSBzdW09MDsKCQkJZWxzZSBpZihzdW0+bWF4KSBtYXg9c3VtOwoJCX0KCQlwcmludGYoIiVkXG4iLG1heCk7Cgl9CglyZXR1cm4gMDsKfQ==