#P2383. Forming a Square with Sticks

    ID: 15655 Type: Default 1000ms 256MiB

Forming a Square with Sticks

Forming a Square with Sticks

Given a set of wooden sticks, determine if it is possible to use all of them (without breaking any) to form a square. In other words, can the sticks be partitioned into 4 groups such that each group sums up to the same value? The side length of the square, if it exists, is \(\frac{\text{total sum of sticks}}{4}\).

inputFormat

The first line contains an integer \(n\) representing the number of sticks. The second line contains \(n\) space-separated integers, each representing the length of a stick.

outputFormat

Output Yes if it is possible to form a square using all the sticks, otherwise output No.

sample

5
1 1 2 2 2
Yes