#include <stdio.h>
#include <string.h>
long long max(long long a, long long b)
{
return a > b?a:b;
}
int main()//原題,資料範圍最大支援2^63 - 1 -> -2^63
long long maxn = 0, sum = 0, maxi = 1LL<<63, a;
int n;
scanf("%d",&n);
while(n--)
scanf("%lld",&a);
maxi = max(maxi, a);
sum += a;
if (sum < 0)
sum = 0;
maxn = max(maxn, sum);
if (maxi < 0)
printf("%lld\n",maxi);
else
printf("%lld\n",maxn);
return 0;
int run()//提高部分,結束的時候需要檔案結束符
while(scanf("%lld",&a) != -1)
#include <stdio.h>
#include <string.h>
long long max(long long a, long long b)
{
return a > b?a:b;
}
int main()//原題,資料範圍最大支援2^63 - 1 -> -2^63
{
long long maxn = 0, sum = 0, maxi = 1LL<<63, a;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%lld",&a);
maxi = max(maxi, a);
sum += a;
if (sum < 0)
sum = 0;
maxn = max(maxn, sum);
}
if (maxi < 0)
printf("%lld\n",maxi);
else
printf("%lld\n",maxn);
return 0;
}
int run()//提高部分,結束的時候需要檔案結束符
{
long long maxn = 0, sum = 0, maxi = 1LL<<63, a;
while(scanf("%lld",&a) != -1)
{
maxi = max(maxi, a);
sum += a;
if (sum < 0)
sum = 0;
maxn = max(maxn, sum);
}
if (maxi < 0)
printf("%lld\n",maxi);
else
printf("%lld\n",maxn);
return 0;
}