https://www.nowcoder.com/questionTerminal/df219d60a7af4171a981ef56bd597f7b
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;
long long dp[1000005];
long long A[1000005];
int main()
{
int N;
while(cin>>N)
{
long long maxnum=-2e63+1;
for(int i=0;i<N;i++)
cin>>A[i];
dp[0]=A[0];
for(int i=1;i<N;i++)
{
dp[i]=max(A[i],A[i]+dp[i-1]);
if(dp[i]>maxnum)
maxnum=dp[i];
}
cout<<maxnum<<endl;
}
return 0;
}