#include <iostream>
#include <algorithm>
using namespace std;
long arr[100005],n,sum=0,ans=0,l=0,r=0,temp=0;
int main (){
    cin>>n;
    for(long i=0;i<n;i++)cin>>arr[i],sum+=arr[i];
    while(l<n&&r<n){
        if(temp*2<=sum)ans=max(ans,temp),temp+=arr[r++];
        else temp-=arr[l++];
    }
    while(temp*2>sum&&l<n)temp-=arr[l++];
    ans=max(ans,temp);
    cout<<ans;
    return 0;
}