#include <fstream>
using namespace std;
ifstream cin("ssm.in");
ofstream cout("ssm.out");
long long suma[6000010];
int numere[6000001];
int numar;
int nr;
int maxx=-1e6;
int poz_max=-1e6;
void afisare(int poz,int s)
{
if(s>0)
{
s-=numere[poz];
afisare(s,poz-1);
cout<<suma[poz]<<' ';
}
}
int main()
{
cin>>numar;
for(int indice=1;indice<=numar;++indice)
{
cin>>numere[indice];
nr=numere[indice];
suma[indice]=max(suma[indice-1]+nr,1LL*nr);
if(maxx<suma[indice])
{
maxx=suma[indice];
poz_max=indice;
}
}
return 0;
}