#C897. Equal Subset Partition

    ID: 53010 Type: Default 1000ms 256MiB

Equal Subset Partition

Equal Subset Partition

You are given a list of integers. Your task is to determine whether it is possible to partition the list into two non-empty subsets such that the sum of the elements in each subset is equal. Formally, given a list \(A = [a_1,a_2,\dots,a_n]\) with \(n \ge 2\), decide if there exist two non-empty, disjoint subsets \(S\) and \(T\) with \(S \cup T = A\) such that

[ \sum_{x \in S} x = \sum_{x \in T} x. ]

If such a partition exists, print "YES"; otherwise, print "NO".

inputFormat

The input is given via standard input (stdin) in the following format:

n
a1 a2 ... an

Where the first line contains an integer \(n\) (with \(n \ge 2\)), the number of elements. The second line contains \(n\) space-separated integers representing the elements of the list.

outputFormat

Output a single line to standard output (stdout) containing either "YES" if a valid partition exists, or "NO" otherwise.

## sample
4
1 5 11 5
YES