#include<stdio.h>
int main(void){
   int n, a, i, max = 0, sum[100][100];
   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) {
       scanf("%d", &a);
       if ( i == 0 )sum[0][0] = a;
       else sum[0][i] = sum[0][i - 1] + a;
       if ( max < sum[0][i]) max = sum[0][i];
       printf("sum:%d max:%d\n", sum[0][i], max);
   }
   printf("%d", max[0]);
   return 0;
}