#d2863. 吃糖果

吃糖果

Eating Candies

Problem Description

There are nn candies on a table, arranged from left to right and numbered in that order; the ii-th candy has weight wiw_i. Xiao Ming and Xiao Hong want to eat the candies.

Xiao Ming starts from the left and eats any number of candies (contiguous, without skipping any candy).

Xiao Hong starts from the right and eats any number of candies (contiguous, without skipping any candy).

Of course, if Xiao Ming eats a certain candy, Xiao Hong cannot eat it (and vice versa).

Their goal is to eat the same total weight of candies. What is the maximum total number of candies they can eat together under this condition?

Input Format

The first line contains an integer nn, the number of candies on the table.

The second line contains nn integers w1,w2,…,wnw_1, w_2, \dots, w_n, the weights of the candies from left to right.

Output Format

Output one integer: the maximum total number of candies Xiao Ming and Xiao Hong can eat together while satisfying the condition.

Sample Input

9
7 3 20 5 15 1 11 8 10

Sample Output

7

Constraints

1≤n≤2×1051 \leq n \leq 2 \times 10^5, 1≤wi≤1041 \leq w_i \leq 10^4