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
input = lambda: sys.stdin.readline().rstrip()
import math
import random
from bisect import bisect_right, bisect_left
from itertools import product, permutations, combinations, combinations_with_replacement 
from collections import deque, defaultdict, Counter
from heapq import heapify, heappush, heappop
from functools import lru_cache, reduce
inf = float('inf')
def error(*args, sep=' ', end='\n'):
  print(*args, sep=sep, end=end, file=sys.stderr)
# mod = 1000000007
# mod = 998244353
DIR = [(0, 1), (0, -1), (1, 0), (-1, 0)]
from typing import List, Union


class FenwickTree:

  '''Build a new FenwickTree. / O(N)'''
  def __init__(self, _n_or_a: Union[List[int], int]):
    if isinstance(_n_or_a, int):
      self._size = _n_or_a
      self._tree = [0] * (self._size+1)
    else:
      a = list(_n_or_a)
      self._size = len(a)
      self._tree = [0] + a
      for i in range(1, self._size):
        if i + (i & -i) <= self._size:
          self._tree[i + (i & -i)] += self._tree[i]
    self._s = 1 << (self._size-1).bit_length()

  '''Return sum([0, r)) of a. / O(logN)'''
  def pref(self, r: int) -> int:
    # assert r <= self._size
    ret = 0
    while r > 0:
      ret += self._tree[r]
      r -= r & -r
    return ret

  '''Return sum([l, n)) of a. / O(logN)'''
  def suff(self, l: int) -> int:
    # assert 0 <= l < self._size
    return self.pref(self._size) - self.pref(l)

  '''Return sum([l, r)] of a. / O(logN)'''
  def sum(self, l: int, r: int) -> int:
    # assert 0 <= l <= r <= self._size
    return self.pref(r) - self.pref(l)

  def __getitem__(self, k: int) -> int:
    return self.sum(k, k+1)

  '''Add x to a[k]. / O(logN)'''
  def add(self, k: int, x: int) -> None:
    # assert 0 <= k < self._size
    k += 1
    while k <= self._size:
      self._tree[k] += x
      k += k & -k

  '''Update A[k] to x. / O(logN)'''
  def set(self, k: int, x: int) -> None:
    pre = self.get(k)
    self.add(k, x - pre)

  '''bisect_left(acc)'''
  def bisect_left(self, w: int) -> int:
    i = 0
    s = self._s
    while s:
      if i + s <= self._size and self._tree[i + s] < w:
        w -= self._tree[i + s]
        i += s
      s >>= 1
    return i if w else None

  '''bisect_right(acc)'''
  def bisect_right(self, w: int) -> int:
    i = 0
    s = self._s
    while s:
      if i + s <= self._size and self._tree[i + s] <= w:
        w -= self._tree[i + s]
        i += s
      s >>= 1
    return i

  def show(self) -> None:
    print('[' + ', '.join(map(str, (self.pref(i) for i in range(self._size+1)))) + ']')

  def tolist(self) -> List[int]:
    return [self.__getitem__(i) for i in range(self._size)]

  @classmethod
  def inversion_num(self, a: List[int], compress: bool=False) -> int:
    ans = 0
    if compress:
      a_ = sorted(set(a))
      z = {e: i for i, e in enumerate(a_)}
      fw = FenwickTree(len(a_))
      for i, e in enumerate(a):
        ans += i - fw.pref(z[e])
        fw.add(z[e], 1)
    else:
      fw = FenwickTree(len(a))
      for i, e in enumerate(a):
        ans += i - fw.pref(e)
        fw.add(e, 1)
    return ans

  def __str__(self):
    sub = [self.pref(i) for i in range(self._size+1)]
    return '[' + ', '.join(map(str, (sub[i+1]-sub[i] for i in range(self._size)))) + ']'

  def __repr__(self):
    return 'FenwickTree(' + str(self) + ')'



#  -----------------------  #

n = int(input())
A = list(map(int, input().split()))
fw1 = FenwickTree(A)
fw3 = FenwickTree(A[::-1])
ans = 0
for i in range(n):
  # A[:i]
  s1 = fw1.pref(i)
  i3 = fw3.bisect_left(s1)
  if i3 is None:
    continue
  i3 = n - i3 - 1
  if i3 < i:
    continue
  if fw1.sum(i3, n) == s1:
    ans = s1
print(ans)
