#K58787. Equal Subarray Sum Partition

    ID: 30720 Type: Default 1000ms 256MiB

Equal Subarray Sum Partition

Equal Subarray Sum Partition

Given an array of integers, determine whether it is possible to partition the array into two subarrays such that the sum of the elements in each subarray is equal. In other words, decide if there exists a subset of the array whose sum is exactly half of the total sum of the array.

Mathematically, for an array \(A = [a_1, a_2, \dots, a_n]\), you need to check if there exists a subset \(S \subseteq A\) such that:

\( \sum_{x \in S} x = \frac{1}{2} \sum_{i=1}^{n} a_i \)

inputFormat

The input is provided via standard input (stdin). The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

Output a single line to standard output (stdout): "YES" if the array can be partitioned into two subarrays with equal sum, and "NO" otherwise.

## sample
4
1 5 11 5
YES