Once upon a time Petya and Gena gathered after another programming competition and decided to play some game. As they consider most modern games to be boring, they always try to invent their own games. They have only stickers and markers, but that won't stop them.

The game they came up with has the following rules. Initially, there are n stickers on the wall arranged in a row. Each sticker has some number written on it. Now they alternate turn, Petya moves first.

One move happens as follows. Lets say there are m ≥ 2 stickers on the wall. The player, who makes the current move, picks some integer k from 2 to m and takes k leftmost stickers (removes them from the wall). After that he makes the new sticker, puts it to the left end of the row, and writes on it the new integer, equal to the sum of all stickers he took on this move. 

Game ends when there is only one sticker left on the wall. The score of the player is equal to the sum of integers written on all stickers he took during all his moves. The goal of each player is to maximize the difference between his score and the score of his opponent.

Given the integer n and the initial sequence of stickers on the wall, define the result of the game, i.e. the difference between the Petya's and Gena's score if both players play optimally. 


-----Input-----

The first line of input contains a single integer n (2 ≤ n ≤ 200 000) — the number of stickers, initially located on the wall.

The second line contains n integers a_1, a_2, ..., a_{n} ( - 10 000 ≤ a_{i} ≤ 10 000) — the numbers on stickers in order from left to right.


-----Output-----

Print one integer — the difference between the Petya's score and Gena's score at the end of the game if both players play optimally.


-----Examples-----
Input
3
2 4 8

Output
14

Input
4
1 -7 -2 3

Output
-3



-----Note-----

In the first sample, the optimal move for Petya is to take all the stickers. As a result, his score will be equal to 14 and Gena's score will be equal to 0.

In the second sample, the optimal sequence of moves is the following. On the first move Petya will take first three sticker and will put the new sticker with value  - 8. On the second move Gena will take the remaining two stickers. The Petya's score is 1 + ( - 7) + ( - 2) =  - 8, Gena's score is ( - 8) + 3 =  - 5, i.e. the score difference will be  - 3.

Difficulty: HARD
Tags: Dynamic programming

Game theory
Skill types: Dynamic programming

Starter code:

Solutions:
n = int(input())
a = [0] + list(map(int, input().split()))
dp = [0] * (n + 1)
s = [0] * (n + 1)
for i in range(1, n + 1):
	s[i] = s[i - 1] + a[i]
dp[n] = 0
cur = s[n]
for i in range(n - 1, 0, -1):
	dp[i] = cur
	cur = max(cur, s[i] - dp[i])
print(dp[1])


n = int(input())
a = list(map(int, input().split()))
p = s = sum(a)
for i in range(n - 2, 0, -1):
	s -= a[i + 1]
	p = max(p, s - p)
print(p)


n = int(input())
raw = input().split()
d = []
prev = 0
for i in range(n):
	di = int(raw[i])
	di += prev
	d.append(di)
	prev = di
i = n - 2
cur = d[n - 1]
while i > 0:
	cur = max(cur, d[i] - cur)
	i -= 1
print(cur)


n = int(input())
a = [0] * n
a = list(map(int, input().split()))
for i in range(1, len(a)):
	a[i] += a[i - 1]
ans = a[-1]
for i in range(n - 2, 0, -1):
	ans = max(ans, a[i] - ans)
print(ans)


def f(a):
	n = len(a)
	dp = [0] * n
	s = [0] * (n + 1)
	for i in range(0, n):
		s[i + 1] = s[i] + a[i]
	maxdiffyet = s[n]
	for i in range(n - 2, -1, -1):
		dp[i] = maxdiffyet
		maxdiffyet = max(maxdiffyet, s[i + 1] - dp[i])
	return dp[0]
n = int(input())
a = [int(x) for x in input().split(' ')]
print(f(a))