SDE Path

Partition Array into Two Equal Sum Subsets

Medium

Partition Array into Two Equal Sum Subsets

Determine whether an array can be partitioned into two subsets with equal sums.

Input format

The first line contains N. The second line contains N integers (1–30).

Output format

Print true if the array can be partitioned into two equal-sum subsets, false otherwise. Generate half with even splittable sums.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
13
21 13 26 23 21 12 7 26 4 25 2 27 8
Expected output
false
Example 2
Input
1
21
Expected output
false