#include <fstream>
using namespace std;
long i,a[100000],x = -1000000;
ifstream f1("dconmax.inp");
ofstream f2("dconmax.out");
int main()
{
    f1 >> i;
    for (long n = 0; n < i; n++) f1 >> a[n];
    for (long m = 0; m < i; m++)
	{
		long tong = 0;
		for (long n = m; n < i; n++)
		{
			tong = tong + a[n];
			if (tong > x) x = tong;
		}
	}
	f2 << x;
    return 0;
}
