Balanced sequences

Write a program to tell if a given sequence of integer numbers x₁…x_(n)
is balanced or not. Let m = ⌈n/2⌉. In this problem, we say that a
sequence is balanced if n ≤ 2, or if the left-hand half x₁…x_(m) and the
right-hand half x_(m + 1)…x_(n) have the same sum, and both are
balanced.

For instance, the sequence 5 -3 2 0 -1 3 2 is balanced, because the sum
of 5 -3 2 0 and the sum of -1 3 2 are 4, and it is easy to see that both
sequences are balanced.

Input

Input consists of several cases. Every one begins with n, followed ny n
integer numbers. You can assume 0 ≤ n ≤ 10⁴.

Output

For every case, print “yes” or “no” as required.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:28:31.478Z

© Jutge.org, 2006–2026.
https://jutge.org
