//============================================================================
// Name : mmmmmmmm.cpp
// Author : sameh mohamed
// Copyright : don't try i'm warnning you......
// Description : Hello World
//============================================================================
//Egypt came then History
//Pharoas were coders but using different compilers{}{}{}{}{}}}}{{{{@#$%^^&&$$$###()()(***)))([][][][][]]][
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
long long a[n];
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)
cin>>a[i];
long long s=LONG_MIN;
long long m=0;
for(int i=0;i<n;i++)
{
m+=a[i];
if(m>s)
s=m;
if(m<0)
m=0;
}
cout<<s;
return 0;
}
Copy