#K72527. Balanced Gear Mechanism

    ID: 33773 Type: Default 1000ms 256MiB

Balanced Gear Mechanism

Balanced Gear Mechanism

You are given a gear mechanism with an even number n of gears. Each gear is characterized by its number of teeth. The mechanism is considered balanced if the sum of the teeth counts of the first half of the gears equals the sum of the teeth counts of the second half.

Formally, if the gears have teeth counts \(a_1, a_2, \ldots, a_n\), let \(S_1 = \sum_{i=1}^{n/2} a_i\) and \(S_2 = \sum_{i=n/2+1}^{n} a_i\). The mechanism is balanced if and only if \(S_1 = S_2\).

Your task is to determine whether the gear mechanism is balanced. If it is, print YES; otherwise, print NO.

inputFormat

The input consists of two lines:

  1. The first line contains an even integer n (\(2 \le n \le 10^5\)), representing the number of gears.
  2. The second line contains n space-separated integers, where each integer denotes the number of teeth on a gear.

outputFormat

Output a single line with the string YES if the gear mechanism is balanced; otherwise, output NO.

## sample
4
10 20 20 10
YES