import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int left=0,right=n-1;
        long lo=nums[0],hi=nums[n-1],res=0;;
        while(left<right){
            if(lo<hi){
                left++;
                lo+=nums[left];
                
            }
            else if(lo>hi){
                right--;
                hi+=nums[right];
                
            }
            else{
                if(res<lo)
                    res=lo;
                left++;
                lo+=nums[left];
                right--;
                hi+=nums[right];
            }
        }
        System.out.println(res);
    }
    
双指针方法