Problem1521--CF839 - B. Game of the Rows

1521: CF839 - B. Game of the Rows

[Creator : ]
Time Limit : 2.000 sec  Memory Limit : 256 MiB

Description

Daenerys Targaryen has an army consisting of $k$ groups of soldiers, the $i$-th group contains $a_i$ soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane hasnrows, each of them has8seats. We call two seats neighbor, if they are in the same row and in seats {1,2},{3,4},{4,5},{5,6} or {7,8}.
 
A row in the airplane
Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.
Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.

Input

The first line contains two integers $n,k\ (1≤n≤10000,\ 1≤k≤100)$ − the number of rows and the number of groups of soldiers, respectively. 
The second line contains $k$ integers $a_1,a_2,a_3,...,a_k\ (1≤a_i≤10000)$, where $a_i$ denotes the number of soldiers in the $i$-th group. It is guaranteed that $a_1+a_2+...+a_k≤8·n$.

Output

If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes).

Sample 1 Input

2 2
5 8

Sample 1 Output

YES
Daenerys can place the soldiers like in the figure below:

Sample 2 Input

1 2
7 1

Sample 2 Output

NO
there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.

Sample 3 Input

1 4
2 2 1 2

Sample 3 Output

YES
Daenerys can place the first group on seats (1,2,7,8), and the second group an all the remaining seats.

1 4
2 2 1 2

YES
she can place the first two groups on seats (1,2) and (7,8), the third group on seats (3), and the fourth group on seats (5,6).

HINT

Source/Category