#include <bits/stdc++.h>
using namespace std;
int n,arr[100005];
int main(){
int ans = 0;
cin >> n;
for (int i = 0;i < n;i++){
cin >> arr[i];
ans += arr[i];
}
int son1 = arr[0],son2 = arr[n - 1];
int l = 0,r = n - 1;
int cur = ans - son1 - son2;
if (son1 == son2) ans = cur;
while(l < r){
if (son1 == son2) {
ans = cur;
l++;
son1 += arr[l];
cur -= arr[l];
}
while(l < r && son1 < son2){
l++;
son1 += arr[l];
cur -= arr[l];
}
while(l < r && son1 > son2){
r--;
son2 += arr[r];
cur -= arr[r];
}
}
cout << ans;
return 0;
}