//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define dd double
#define ld long double
#define ull unsigned long long
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define el "\n"
#define Arwa ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fix(x) cout << fixed << setprecision(x)
#define all(v) v.begin(),v.end()
void file()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
bool prime(int n) {
if (n == 2) return true;
if (n % 2 == 0 || n == 1) return false;
for (int i = 3; i * i <= n; i += 2)
if (n % i == 0) return false;
return true;
}
//Here We Go Again
int32_t main()
{
Arwa
int t=1;
//cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
map<int,bool>m1,m2;
for(int i=0;i<n;i++)
cin>>arr[i];
bool f=1;
int s=0,e=n-1,sum1=0,sum2=0,mx=-1e9;
while(s<=e)
{
if(f)
{
sum1+=arr[s];
s++;
f=0;
}
else
{
sum2+=arr[e];
e--;
f=1;
}
m1[sum1]=1;
m2[sum2]=1;
if(m2[sum1])
mx=max(mx,sum1);
if(m1[sum2])
mx=max(mx,sum2);
}
cout<<max(mx,0)<<el;
}
return 0;
}
Ly8jaW5jbHVkZSA8ZXh0L3BiX2RzL2Fzc29jX2NvbnRhaW5lci5ocHA+IAovLyNpbmNsdWRlIDxleHQvcGJfZHMvdHJlZV9wb2xpY3kuaHBwPiAKLy91c2luZyBuYW1lc3BhY2UgX19nbnVfcGJkczsgCi8vI2RlZmluZSBvcmRlcmVkX3NldCB0cmVlPGludCwgbnVsbF90eXBlLGxlc3M8aW50PiwgcmJfdHJlZV90YWcsdHJlZV9vcmRlcl9zd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0KLy9IZXJlIFdlIEdvIEFnYWluCmludDMyX3QgbWFpbigpIAp7CiAgICBBcndhCiAgICBpbnQgdD0xOwogICAgLy9jaW4+PnQ7CiAgICB3aGlsZSh0LS0pIAogICAgewogICAgICBpbnQgbjsKICAgICAgY2luPj5uOwogICAgICBpbnQgYXJyW25dOwogICAgICBtYXA8aW50LGJvb2w+bTEsbTI7CiAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspCiAgICAgIGNpbj4+YXJyW2ldOwogICAgICBib29sIGY9MTsKICAgICAgaW50IHM9MCxlPW4tMSxzdW0xPTAsc3VtMj0wLG14PS0xZTk7CiAgICAgIHdoaWxlKHM8PWUpCiAgICAgIHsKICAgICAgICBpZihmKQogICAgICAgIHsKICAgICAgICBzdW0xKz1hcnJbc107CiAgICAgICAgcysrOwogICAgICAgIGY9MDsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICBzdW0yKz1hcnJbZV07CiAgICAgICAgZS0tOwogICAgICAgIGY9MTsKICAgICAgICB9ICAgIAogICAgICAgIG0xW3N1bTFdPTE7CiAgICAgICAgbTJbc3VtMl09MTsKICAgICAgICBpZihtMltzdW0xXSkKICAgICAgICBteD1tYXgobXgsc3VtMSk7CiAgICAgICAgaWYobTFbc3VtMl0pCiAgICAgICAgbXg9bWF4KG14LHN1bTIpOyAgIAogICAgICB9CiAgICAgIGNvdXQ8PG1heChteCwwKTw8ZWw7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=