Under construction

Still being built. Things may change

Decisive Friday

Interview

Time limit1sMemory limit1024 MB

Summary
Given N job durations in days, decide whether some subset of them can be ordered so the work ends exactly on Friday, 4 days after Monday.
Level

Medium4 of 10

Topics
Dynamic programming, Math
Solved
No attempts yet

Problem

Gomgomi sleeping

Gomgomi made exercise his New Year goal this year too, but he has not once gone to the gym so far. To you, the one who keeps nagging him to work out, Gomgomi says he will go to the gym if there is a moment when he finishes his work exactly on Friday!

It is Monday now. You want to know whether you can rearrange the order of Gomgomi's jobs so that he can be sent to the gym.

Input

The first line contains the number of jobs NN. (1≤N≤1 0001 \le N \le 1\,000)

The second line contains integers A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N separated by spaces. (1≤A1,A2,⋯ ,AN≤100 0001 \le A_1, A_2, \cdots, A_N \le 100\,000)

Output

On the first line, print YES if Gomgomi can be sent to the gym, and NO if he cannot.

Examples3

  1. Example 1

    Input
    3
    4 4 4
    
    Expected output
    YES
    
  2. Example 2

    Input
    5
    5 5 5 5 5
    
    Expected output
    YES
    
  3. Example 3

    Input
    3
    3 3 3
    
    Expected output
    NO