Coins
93% Success10535 Attempts20 Points1s Time Limit256MB Memory1024 KB Max Code

There are \(N\) bags and each bag contains some coin(s). Your task is to select an integer \(X\) and remove all the bags in which the number of coins is equal to \(X\). Divide the remaining bags into two non-empty groups such that:

  1.  The number of coin(s) in each bag of the first group is strictly smaller than \(X\).
  2. The number of coin(s) in each bag of the second group is strictly larger than \(X\).
  3. The total number of coins of one group is equal to the other.

Input Format:

The first line contains an integer \(N\;(1 \le N \le 10^5)\) denoting the number of bags.
The second line contains \(N\) space-separated integers, denoting the number of coins in \(N\) bags. The \(i^{th}\) integer denotes the values of \(A_i \; (1 \le A_i \le 10^5)\).

Output Format:

Print \(YES\), if it is possible to divide the bags into two groups, else print \(NO\).

Examples
Input
5
1 1 2 3 4
Output
YES
Explanation

We can choose X as 3,then there are 3 bags which has less than 3 coins therefore their sum is 1+1+2=4.And there is only one bag with number of coins greater than 3 and their sum is 4. Since value of both sums are equal, the answer is "YES".

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...
Results