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 time
import os,sys
from datetime import datetime
from math import floor,sqrt,gcd,factorial,ceil,log2
from collections import Counter,defaultdict
import bisect
from itertools import chain
from collections import deque
from sys import maxsize as INT_MAX
from itertools import permutations
from collections import deque
#import threading
'''Dont use setrecursionlimit in pypy'''
#sys.setrecursionlimit(int(1e9)+500)
#threading.stack_size(0x2000000)
ONLINE_JUDGE,INF,mod=False,float('inf'),int(1e9)+7
if os.path.exists('D:\\vimstuff'):
	ONLINE_JUDGE=True
	sys.stdin=open('D:\\vimstuff\\inp.txt','r')
	sys.stdout=open('D:\\vimstuff\\out.txt','w')
'''def ceil(a,b):
	return(int((a+b-1)/b))'''

def readint():
	return int(sys.stdin.readline())
def readstr():
	return sys.stdin.readline()
def readlst():
	return list(map(int, sys.stdin.readline().strip().split()))
def readmul():
	return map(int, sys.stdin.readline().strip().split())
def mulfloat():	return map(float, sys.stdin.readline().strip().split())
def flush():
	return sys.stdout.flush()
def power_two(x):
	return (1<<x)
def lcm(a,b):
	return a*b//gcd(a,b)

def countGreater(arr,n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while (l <= r):
		m = int(l + (r - l) / 2)
		if (arr[m] >= k):
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
			return (n - leftGreater)

def lower_bound(arr,n,val):
	l,r=-1,n
	while r>l+1:
		m=int((l+r)>>1)
		if arr[m]<val:
			l=m
		else:
			r=m
	return r

def upper_bound(arr,n,val):
	l,r=-1,n
	while r>l+1:
		m=int((l+r)>>1)
		if arr[m]<=val:
			l=m
		else:
			r=m
	return l

def binpow(a,n,mod):
	res=1
	while n:
		if n&1:
			res=(res*a)%mod
			n-=1
		a=(a*a)%mod
		n=n>>1
	return res

def printmat(l,seperate=True):
	for i in range(0,len(l)):
		if(seperate):
			print(*l[i],sep=" ")
		else:
			print(*l[i],sep="")

def is_perfect_square(num):
	#print(num)
	temp = num**(0.5)
	#print(temp)
	return (temp//1)==temp

def find(res):
	n1=res
	while par[n1]!=n1:
		par[n1]=par[par[n1]]
		n1=par[n1]
	return n1

def union(u,v):
	p1,p2=find(u),find(v)
	if p1==p2:
		return 0
	if(rank[p1]>rank[p2]):
		p1,p2=p2,p1
	par[p1]=p2
	rank[p2]+=rank[p1]
	return 1

'''
1. Implement after understanding properly don't do in vain.
2. Check corner cases.
3. Use python if there is recursion,try-catch,dictionary.
4. Use pypy if heavy loop,list slice.
'''


def john_3_16():
	n=readint()
	a=readlst()
	l,r=0,n-1
	ans,a1,a2=0,0,0
	while l<r:
		if a[l]+a1<a[r]+a2:
			a1+=a[l]
			l+=1
		elif a[l]+a1>a[r]+a2:
			a2+=a[r]
			r-=1
		else:
			a1,a2=a[l]+a1,a[r]+a2
			ans=max(ans, a1)
			l+=1;r-=1
	print(ans)
	return
	


	
def main():
	#tc=readint()
	tc=1
	#cnt=0
	start=time.time()
	#cnt=1
	while tc:
		john_3_16()
		tc-=1
		#cnt+=1
	if ONLINE_JUDGE:
		print(f'{(time.time()-start)*1000}ms')
		pass
main()
