You are given an array $d_1, d_2, \dots, d_n$ consisting of $n$ integer numbers.

Your task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and each of the parts forms a consecutive contiguous subsegment (possibly, empty) of the original array. 

Let the sum of elements of the first part be $sum_1$, the sum of elements of the second part be $sum_2$ and the sum of elements of the third part be $sum_3$. Among all possible ways to split the array you have to choose a way such that $sum_1 = sum_3$ and $sum_1$ is maximum possible.

More formally, if the first part of the array contains $a$ elements, the second part of the array contains $b$ elements and the third part contains $c$ elements, then:

$$sum_1 = \sum\limits_{1 \le i \le a}d_i,$$ $$sum_2 = \sum\limits_{a + 1 \le i \le a + b}d_i,$$ $$sum_3 = \sum\limits_{a + b + 1 \le i \le a + b + c}d_i.$$

The sum of an empty array is $0$.

Your task is to find a way to split the array such that $sum_1 = sum_3$ and $sum_1$ is maximum possible.
The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of elements in the array $d$.

The second line of the input contains $n$ integers $d_1, d_2, \dots, d_n$ ($1 \le d_i \le 10^9$) — the elements of the array $d$.
5
1 3 1 1 4
5
5
1 3 2 1 4
4
3
4 1 2
0
1
1000000000
0
2
1 1
1
5
1 3 5 4 5
9
import sys
from os import path
if(path.exists('Input.txt')):
    sys.stdin = open("Input.txt","r")
    sys.stdout = open("Output.txt","w")
    
from queue import PriorityQueue
from math import gcd,floor,sqrt,log,ceil,inf
import math
from collections import *
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
def li(): return list(map(int, sys.stdin.readline().split()))
def mp(): return map(int, sys.stdin.readline().split())
def inp(): return int(sys.stdin.readline())
def st(): return list(sys.stdin.readline().strip())
def out(*l): return print(*l)
def pr(n): return sys.stdout.write(str(n)+"\n")
def prl(n): return sys.stdout.write(str(n)+" ")
M = 1000000007
INF = float('inf')
yes, no = "YES", "NO"
import operator as op
from functools import reduce
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom
def fact(n):
	return math.factorial(n)
def perfect(n):
	return floor(sqrt(n))==ceil(sqrt(n))
def lcm(a, b):
    return a * b // gcd(a, b)
def binary_search(array, target, start, end):
    while start <= end:
        mid = (start + end) // 2
        if array[mid] == target:
            return mid
        elif array[mid] > target:
            end = mid - 1
        else:
            start = mid + 1
    return -1
def isPrime(n):
	if (n % 2 == 0 and n != 2) or n < 2:
	    return False
	i = 3
	while i * i <= n:
	    if n % i == 0:
	        return False
	    i += 2
	return True
def expo(a, n, k):
    ans = 1
    while(n > 0):
        last_bit = n&1
        if(last_bit):
            ans = (ans*a)%k
        a = (a*a)%k
        n = n >> 1
    return ans
def prefix_sum(arr):
	n=len(arr)
	l = [arr[0]]
	for i in range(1,n):
		x = l[-1]
		l.append(x+arr[i])
	return l
    
def solve():
	n=inp()
	l=li()
	a=0
	b=n-1
	mx = 0
	x1=l[a]
	x2=l[b]
	while 1:
		if(x1==x2):
			mx=max(mx,x1)
			a+=1
			if(a>=b):
				break
			x1+=l[a]
		if(x1>x2):
			b-=1
			if(a>=b):
				break
			x2+=l[b]
		if(x2>x1):
			a+=1
			if(a>=b):
				break
			x1+=l[a]
	pr(mx)
		
for _ in range(1):
	#prl(f"Case #{_+1}:")
	solve()