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

#ort math
# # # def mid(x,y,posX,posY):
# # #     z = len(x) + len(y)
# # #     if -float('inf') in x :
# # #         z+=1
# # #         posX+=1
# # #     if -float('inf') in y :
# # #         z+=1
# # #         posY+=1
# # #     if float('inf') in x :
# # #         z+=1
# # #     if float('inf') in y :
# # #         z+=1
# # #     if (z)%2 == 0 :
# # #         m =(max(x[posX-1],y[posY-1])+min(x[posX],y[posY]))/2
# # #     else :
# # #         m = max(x[posX-1],y[posY-1])
# # #     return m
# # # x = [23,26,31,35]
# # # y = [3,5,7,9,11,16]
# # # xy = x+y
# # # xy.sort()
# # # print(xy)
# # # xyp = (len(x)+len(y)+1)//2


# # # start = 0
# # # end = len(x)-1
# # # while True:
# # #     posX = (start+end+1)//2
# # #     posY = xyp - posX
# # #     if x[posX-1] <= y[posY] and x[posX] >= y[posY-1] :
# # #         ans = mid(x,y,posX,posY)
# # #         break
# # #     if posX == 0 :
# # #         x.insert(0,-float('inf'))
# # #         ans = mid(x,y,posX,posY)
# # #         break
# # #     elif posX == len(x)-1:
# # #         x.append(float('inf'))
# # #         ans = mid(x,y,posX,posY)
# # #         break
# # #     if posY == 0 :
# # #         y.insert(0,-float('inf'))
# # #         ins = mid(x,y,posX,posY)
# # #         break
# # #     elif posY == len(y)-1:
# # #         y.append(float('inf'))
# # #         ans = mid(x,y,posX,posY)
# # #         break
# # #     # continue the binarry search on x
# # #     if x[posX] < y[posY-1]:
# # #         start = posX
# # #     elif x[posX-1] > y[posY]:
# # #         end = posX-1
# # #     else :
# # #         start = posX
# # # print(ans)
# # def pow(x,n):
# #     if n == 0 :
# #         return 1 
# #     elif x == 0 :
# #         return 0 
# #     else :
# #         return x * pow(x,n-1)
    
# # # using devide and conquer 
# # def pow(x,n):
# #     if n == 0 :
# #         return 1 
# #     elif n%2 == 0 :
# #         return pow(x,n//2)*pow(x,n//2) 
# #     else :
# #         return x*pow(x,n//2)*pow(x,n//2)
    
# # # optimization 
# # def pow(x,n):
# #     temp = 0 
# #     if n == 0 :
# #         return 1 
# #     temp = pow(x,n//2)
# #     if n%2 == 0 :
# #         return temp*temp 
# #     else :
# #         return x*temp*temp

# # print(pow(3,3))
# import math
# aa = []
# for i in range(int(input())):
#     n = int(input())
#     l = list(map(int,input().split()))
#     ll = l.copy()
#     lll = l.copy()
#     lll.sort(reverse=True)
#     ll.sort()
#     if l == ll :
#         aa.append(0)
#     elif l == lll:
#         aa.append(max(l))
#     else :
#         ans = []
#         modl = []
#         for i in range(1,len(l)):
#             if l[i]!=l[i-1]:
#                 ans.append(math.ceil((l[i]+l[i-1])/2))
#         e = max(ans)
#         for i in l :
#             modl.append(abs(i-e))
#         modll = modl.copy()
#         modl.sort()
#         if modl == modll :
#             aa.append(e)
#         else :
#             aa.append(-1)
    
# for i in aa :
#     print(i)l
###########################
# first Element more than e 
lis = [10,25,37]
l = 0 
r = len(lis)-1
e = 25
def c(lis,l,r,e):
    ans = 0
    while l<= r :
        m = (l+r)//2 
        if lis[m] > e :
            r = m-1
        else :
            l = m+1 
            ans = l
    return ans
######################################
# lis = [1,2,3,4,5]
# l = 0 
# r = len(lis)-1
# e = 0
# ans = -1
# while l<=r :
#     m = (l+r)//2 
#     if lis[m] <= e :
#         ans = l
#         l = m+1  
#     else :
#         r = m-1 
# def f(l,i,j,n,m):
#     c = l[i][j]
#     i1 = i 
#     j1 = j
#     i2 = i 
#     j2 = j
#     i3 = i 
#     j3 = j
#     i4 = i 
#     j4 = j
#     while i1 > 0 and j1 > 0 :
#         i1-=1 
#         j1-=1 
#         c+=l[i1][j1]
#     while i2 < n-1 and j2 < m-1 :
#         i2+=1
#         j2+=1 
#         c+=l[i2][j2]
#     while i3 > 0 and j3 < m-1 :
#         i3-=1 
#         j3+=1 
#         c+=l[i3][j3]
#     while i4 < n-1 and j4 > 0 :
#         i4+=1 
#         j4-=1 
#         c+=l[i4][j4]
#     return c 
# n,k = map(int,input().split())
# l = []
# for i in range(1,n+1):
#     l.append(i*5)
# ll = [l[0]]
# for i in range(1,n):
#     ll.append(l[i]+ll[i-1])
# e = 240 - k 
# print(c(ll,0,n-1,e))
# fastPower
def func(x,n):
    if n == 0 :
        return 1
    if n % 2 == 0 :
        return (func(x**2,n//2))
    else :
        return (x*func(x,n-1))

def gcd(a,b):
    if b == 0 :
        return a 
    else :
        return gcd(b,a%b) 

def lcm(a,b):
    return a/gcd(a,b)*b

def exeteclidain(a,b,x,y):
    if b == 0 :
        x = 1 
        y = 0 
        return a 
    x1 = 0 
    y1 = 0 
    d = exeteclidain(b,a%b,x1,y1)
    x = y1 
    y = x1-y1*(a//b)
    return

import math

def sieve(n):
    l = [0]*(n+1)
    l[0] = l[1] = 1 
    for i in range(2,int(n**.5)+1):
        if not l[i]:
            for j in range(i*i,n+1,i):
                l[j] = 1 
    return [i for i in range(n+1) if l[i] == 0]



def sieveOptemised(n,prime):
    l = [0]*(n+1)
    l[0] = l[1] = 1 
    for i in range(2,n):
        if not l[i] : prime.append(i) 
        for j in range(len(prime)):
            if i*prime[j] >= n :
                break
            l[i*prime[j]] = 1 
            if i % prime[j] == 0 : break 

prime = []
sieveOptemised(7+1,prime)

def binarySearch(arr, x):
    n = len(arr)
    if n == 1:
        if arr[0] == x:
            return 0
        else:
            return True # not in list
    else:
        m = int(n/2)
        if x <= arr[m]:
            return binarySearch(arr[:m], x)
        else:
            return m + binarySearch(arr[m:], x)

import random
def fermatTesting(n,k) :
    if n == 1 or n == 4 :
        return False
    elif n == 2 or n == 3 :
        return True 
    for i in range(k):
        a = random.randint(2,n-2)
        # check a**(n-1)%n == 1 or not
        if pow(a,n-1,n)!= 1 :
            return False 
    return True
import math
def check10(n):
    c = 0 
    while n >= 10 :
        c+=n%10 
        n=n//10 
    c+=n 
    if c == 10 : return 1 
    return 0

def increase(n):
    n = (str(n))
    c = 0 
    ind = -1 
    for i in range(len(n)) :
        c+=int(n[i])
        if c >= 10 :
            ind = i 
            break 
    if ind == -1 :
        return int(n)+1 
    else :
        add = int("1"+"0"*(len(n)-i)) - int(n[ind:])
        return int(n)+add
def binary_search(lis, l, e):
    r = len(lis)-1
    while l <= r:
        m = (l + r) // 2
        if lis[m] == e:
            return 1
        elif lis[m] > e:
            r = m - 1
        else:
            l = m + 1
    return 0
n = int(input())
l = list(map(int,input().split()))
l1 = [l[0]]
l2 = [l[-1]]
for i in range(1,n):
    l1.append(l[i]+l1[i-1])
for i in range(n-2,-1,-1):
    l2.append(l[i]+l2[-1])

ans = 0 
for i in range(n-1):
    x = l1[i]
    y = binary_search(l2[:n-i-1],0,x)
    if y :
        ans = x
print(ans)




