import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

        int n = in.nextInt();
        long[] arr = new long[n];
        for(int i=0;i<n;i++){
            arr[i] = in.nextLong();
        }
        long max = 0;
        int i=0,j=n-1;
        long leftsum = arr[0];
        long rightsum = arr[n-1];
        while(i<j){
            //if(arr[i]==0||arr[j]==0) return;//没用,题目说正整数
            if(leftsum==rightsum){
                max = Math.max(leftsum,max);
                i++;
                j--;
                leftsum+=arr[i];
                rightsum+=arr[j];
            }
            if(leftsum>rightsum){
                j--;
                rightsum+=arr[j];
            }
            if(rightsum>leftsum){
                i++;
                leftsum+=arr[i];
            }
        }
        System.out.println(max);
        
        
    }
}