Under construction

Still being built. Things may change

Divvying Up

Interview

Time limit2sMemory limit512 MB

Summary
Given prize amounts from n contests, decide whether each total can be split among three team members so all three end with equal sums.
Level

Easy3 of 10

Topics
Math, Implementation, Array, Greedy
Solved
No attempts yet

Problem

A solid competitive programming team can rack up a lot of prize money. Knowing how strong your team is, you are certain to win a lot of contests, so you had better sit down now and check that everybody will receive the same fair distribution of winnings.

You will participate in multiple contests, and at the end of each one receive a set amount of prize money. You can distribute any amount to each of the three members of your team each time, but by the end everyone must have the same amount of total winnings.

Can you distribute the winnings such that everyone gets an equal amount by the end?

Input

  • One line containing the number of contests, nn (1≤n≤1041 \le n \le 10^4).
  • One line containing the prize purse for each contest, w_1…w_nw\_1 \ldots w\_n (1≤w≤1051 \le w \le 10^5).

Output

Output yes if the winnings can be distributed equally between three contestants, otherwise no.

Examples2

  1. Example 1

    Input
    2
    10 3
    
    Expected output
    no
    
  2. Example 2

    Input
    3
    9 8 7
    
    Expected output
    yes