#include <iostream>
#include <vector>
using namespace std;
int getMax(int a, int b){
return a>b? a:b;
}
int main(){
int num;
cin >> num;
vector<int> arr;
arr.resize(num);
for(int i=0; i<num; ++i){
cin >> arr[i];
}
int sum = arr[0];
int maxSum = arr[0];
for(int i=1; i<num; ++i){
sum = getMax(arr[i], sum+arr[i]);
if(sum > maxSum){
maxSum = sum;
}
}
cout << maxSum;
return 0;
}
#include <vector>
using namespace std;
int getMax(int a, int b){
return a>b? a:b;
}
int main(){
int num;
cin >> num;
vector<int> arr;
arr.resize(num);
for(int i=0; i<num; ++i){
cin >> arr[i];
}
int sum = arr[0];
int maxSum = arr[0];
for(int i=1; i<num; ++i){
sum = getMax(arr[i], sum+arr[i]);
if(sum > maxSum){
maxSum = sum;
}
}
cout << maxSum;
return 0;
}