#include<iostream>
using namespace std;
int n, a[110], sum[110];
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
for (int j = i; j <= n; j++)
{
ans = max(ans, sum[j] - sum[i - 1]);
}
}
cout << ans << endl;
return 0;
}