import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
//将数组分为三组,1,3两组金额要相等,可维护两个指针分别从首尾开始遍历,
// 如果金额相等就保存,直到两指针相遇,返回最大相等的金额
int left = 0,right = n - 1;
int leftSum = 0,rightSum = 0;
long maxSum = 0;//最大金额
leftSum += arr[left];
rightSum += arr[right];
while (left < right){
if (leftSum < rightSum){
leftSum += arr[++left];
}else if (leftSum > rightSum){
rightSum += arr[--right];
}else if (leftSum == rightSum){
maxSum = Math.max(maxSum,leftSum);
leftSum += arr[++left];
rightSum += arr[--right];
}
}
System.out.println(maxSum);
}
}