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 math,sys,collections,bisect,heapq


def natural(n):
	return n*(n+1)//2

def possible(arr,h,k):
	for i in range(len(arr)-1):
		if h <= 0:
			return True
		h-=min(arr[i+1]-arr[i],k)
	h-=k
	if h <=0:
		return True
	return False

def binarysearch(l,r,arr,h):
	if l<=r:
		mid = (l+r)//2
		if possible(arr,h,mid):
			return binarysearch(l,mid-1,arr,h)
		return binarysearch(mid+1,r,arr,h)
	return l
def binarysearch2(l,r,k,st):
	if l<=r:
		mid = (l+r)//2
		if mid-st+1==k:
			return mid
		elif mid-st+1<k:
			return binarysearch2(mid+1,r,k,st)
		return binarysearch2(l,mid-1,k,st)
	return -1
def ispossible(n):

	h = 1
	num = 2
	pre = 2
	while num<=n:
		pre = num
		h+=1
		num+=(h*2)+h-1
	return n-pre

def cal(n):
	tmp = 0
	while n:
		tmp+=n%10
		n//=10
	return tmp
def solve():
	n = int(input())
	arr = list(map(int,input().split()))
	l = 0
	r = n-1
	s1 = 0
	s2 = 0
	m = 0
	while l<r:
		if s1 == s2:
			m = s1
			s1+=arr[l]
			s2+=arr[r]
			l+=1
			r-=1
		elif s1<s2:
			s1+=arr[l]
			l+=1
		else:
			s2+=arr[r]
			r-=1
	if s1 == s2:
		m = s1
	print(m)


















































# number of test cases


#t = int(input())
t = 1
for i in range(t):
	solve()









