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 has n rows, each of them has 8 seats. 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}.

 [Image] 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 and 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).

You can choose the case (lower or upper) for each letter arbitrary.


-----Examples-----
Input
2 2
5 8

Output
YES

Input
1 2
7 1

Output
NO

Input
1 2
4 4

Output
YES

Input
1 4
2 2 1 2

Output
YES



-----Note-----

In the first sample, Daenerys can place the soldiers like in the figure below:

 [Image] 

In the second sample, 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.

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

In the fourth example 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).

Difficulty: interview

Starter code:

Solutions:
import sys

def r():
    return list(map(int, input().split()))

n, k = list(map(int, input().split()))
a = r()

cnt4 = n
cnt2 = 2*n
cnt1 = 0
for i in range(k):
    x = min((a[i]+1)//4, cnt4)
    cnt4 -= x
    a[i] = max(0, a[i]-4*x)

cnt2 += cnt4
cnt1 += cnt4
for i in range(k):
    x = min(a[i]//2, cnt2)
    cnt2 -= x
    a[i] = max(0, a[i]-2*x)

cnt1 += cnt2
for i in range(k):
    cnt1 -= a[i]

if (cnt1 < 0):
    print('NO')
else:
    print('YES')


    



# encoding:utf-8

def main():
	n, k = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	
	seat_two = n * 2
	seat_four = n
	seat_one = 0
	n_four = sum([x // 4 for x in nums])
	nums = [x % 4 for x in nums]
	n_two = sum([x // 2 for x in nums])
	n_one = sum([x % 2 for x in nums]) 

	#print(n_one, n_two, n_four)
	#print(seat_one, seat_two, seat_four)

	if seat_four >= n_four:
		# there is rest of 4 seat
		seat_four -= n_four
		n_four = 0

		# break seat seat_one and seat_two
		seat_two += seat_four
		seat_one += seat_four
		seat_four = 0
	else:
		# there is rest of 4 people
		n_four -= seat_four
		seat_four = 0

		# break 4 people to 2, 2
		n_two += n_four * 2
		n_four = 0

	#print(n_one, n_two, n_four)
	#print(seat_one, seat_two, seat_four)


	if seat_two >= n_two:
		seat_two -= n_two
		n_two = 0
		if seat_two + seat_one >= n_one:
			print("YES")
		else:
			print("NO")
	else:
		n_two -= seat_two
		seat_two = 0
		n_one += n_two * 2
		if seat_one >= n_one:
			print("YES")
		else:
			print("NO")

def __starting_point():
	main()
1
__starting_point()

n, k = list(map(int, input().strip().split()))
groups = list(map(int, input().strip().split()))


def fetch(delim, num_places):
    for i, g in enumerate(groups):
        num_g = min(g//delim, num_places)
        g -= num_g*delim
        num_places -= num_g
        groups[i] = g

        if num_places == 0:
            break

    return num_places

num_4 = fetch(4, n)
num_2 = fetch(2, 2*n) + num_4
num_2 += fetch(2, num_4)
if sum(groups) <= num_2:
    print("YES")
else:
    print("NO")


n,k = list(map(int, input().split()))
A = list(map(int, input().split()))

middles = n
sides = n*2
singles = 0

for i,a in enumerate(A):
    s = a//4
    s = min(s, middles)
    middles -= s
    A[i] -= 4*s

for i,a in enumerate(A):
    s = a//2
    s = min(s, sides)
    sides -= s
    A[i] -= 2*s

for i,a in enumerate(A):
    s = a//2
    s = min(s, middles)
    middles -= s
    singles += s
    A[i] -= 2*s

singles += sides
singles += middles*2

for i,a in enumerate(A):
    s = a
    s = min(s, singles)
    singles -= s
    A[i] -= s

rem = sum(A)

if rem == 0:
    print("YES")
else:
    print("NO")



def func(a):
	if(a<0):
		return 0
	else:
		return a

n,k=list(map(int,input().split()))
l=list(map(int,input().split()))
two = 2*n
four = n
baki=[]
for val in l:
	if(val>=4):
		ans=min(four,val//4)
		val=val-ans*4
		four-=ans
	ans=min(two,(val)//2)
	val=val-ans*2
	two-=ans
	baki.append(func(val))
store=sum(baki)
if(store==0):
	print("YES")
elif(store>0 and four==0 and two==0):
	print("NO")
else:
	baki.sort(reverse=True)
	cap1=four
	cap2=four
	for val in baki:
		if(val==3):
			if(cap1>0 and cap2>0):
				cap1-=1
				cap2-=1
			else:
				two-=2
		elif(val==2):
			if(two>0):
				two-=1
			else:
				if(cap1>0):
					cap1-=1
				else:
					cap2-=2
		elif(val==1):
			if(cap2>0):
				cap2-=1
			elif(cap1>0):
				cap1-=1
			else:
				two-=1
	if(cap2<0 or cap1<0 or two<0):
		print("NO")
	else:
		print("YES")
		



		




n, m = list(map(int, input().split()))
z = list(map(int, input().split()))
h = z[:]
double = 2 * n
four = n
jj = []
for i in range(len(h)):
    while four > 0 and h[i] >= 4:
        h[i] -= 4
        four -= 1
    if (h[i] != 0):
        jj.append(h[i])
ss = []
for i in range(len(jj)):
    while four > 0 and jj[i] >= 3:
        jj[i] -= 3
        four -= 1
    if jj[i] != 0:
        ss.append(jj[i])

tt = []
for i in range(len(ss)):
    while double > 0 and ss[i] >= 2:
        ss[i] -= 2
        double -= 1
    if ss[i]:
        tt.append(ss[i])

places = double + four * 2
gg = []
for i in range(len(tt)):
    while four > 0 and tt[i] >= 2:
        tt[i] -= 2
        places -= 1
        four -= 1
    if tt[i]:
        gg.append(tt[i])
if (sum(gg) <= places):
    print("YES")
else:
    print("NO")

    


    


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

s2 = 2 * n
s4 = n
s1 = 0

tmp = sum([ai // 4 for ai in a])
s4 -= min(tmp, n)
s2 -= 2 * max(tmp - n, 0)

for ai in a:
    if ai % 4 == 2:
        if 0 < s2:
            s2 -= 1
        elif 0 < s4:
            s4 -= 1
            s1 += 1
        else:
            s1 -= 2

for ai in a:
    if ai % 4 == 1:
        if 0 < s1:
            s1 -= 1
        elif 0 < s2:
            s2 -= 1
        else:
            s4 -= 1
            s2 += 1

for ai in a:
    if ai % 4 == 3:
        if 0 < s4:
            s4 -= 1
        elif 1 < s2:
            s2 -= 2
        elif 1 == s2:
            s2 -= 1
            s1 -= 1
        else:
            s1 -= 3

if 0 <= s1 and 0 <= s2 and 0 <= s4:
    print("YES")
else:
    print("NO")


import sys


def main():
    n, k = list(map(int, sys.stdin.readline().split()))
    x = list(map(int, sys.stdin.readline().split()))
    ch = n
    dv = 2 * n

    for i in range(k):
        if x[i] % 4 == 2 and dv > 0:
            x[i] -= 2
            dv -= 1
    for i in range(k):
        while x[i] > 3 and ch > 0:
            x[i] -= 4
            ch -= 1

    for i in range(k):
        if x[i] % 4 == 1 and dv > 0:
            x[i] -= 1
            dv -= 1

    for i in range(k):
        while x[i] >= 3 and ch > 0:
            x[i] -= 4
            ch -= 1
    p1 = 0
    p2 = 0
    for i in range(k):
        if x[i] == 2:
            if p2 > 0:
                p2 -= 1
                x[i] = 0
            elif ch > 0:
                x[i] = 0
                p1 += 1
                ch -= 1
            elif p1 > 1:
                p1 -= 2
                x[i] = 0
        elif x[i] == 1:
            if p1 > 0:
                p1 -= 1
                x[i] = 0
            elif ch > 0:
                p2 += 1
                x[i] = 0
                ch -= 1
            elif p2 > 0:
                p2 -= 1
                x[i] = 0

        while x[i] > 0 and dv > 0:
            x[i] -= 2
            dv -= 1

    ok = True
    for i in range(k):
        if x[i] > 0:
            ok = False
            break

    if ok:
        print("YES")
    else:
        print("NO")


main()


n, k = map(int, input().split())
seat = {4:n, 2:n*2, 1:0}
extra1 = 0
a = sorted(map(int, input().split()), reverse=True)

def sit(n, m):
    num = min(seat[n], m)
    seat[n] -= num
    return m - num

for m in a:
    p4 = m // 4
    p3, p2, p1 = 0, 0, 0
    if m%4 == 3:
        p3 = 1
    else:
        p2 = int(m % 4 > 1)
        p1 = int(m % 2)

    extra4 = sit(4, p4)
    p2 += extra4*2
    if sit(4, p3) > 0:
        p2 += 1
        p1 += 1

    extra2 = sit(2, p2)
    x = sit(4, extra2)
    seat[1] += extra2 - x
    p1 += x * 2

    extra1 += p1

extra1 = sit(1, extra1)
x = sit(4, extra1)
seat[2] += extra1 - x
y = sit(2, x)

if y > 0:
    print("NO")
else:
    print("YES")

import sys
n, k = [ int(x) for x in input().split() ]
arr = list( map( int, input().split()) )

cnt_2 = 2 * n
cnt_4 = n
cnt_1 = 0

i = 0
while(cnt_4 > 0 and i < k):
    tmp = int(arr[i] / 4)
    if(tmp > 0 and cnt_4 > 0):
        arr[i] = arr[i] - 4 * min(tmp, cnt_4)
        cnt_4 = cnt_4 - min(tmp, cnt_4)
    i = i + 1

if(cnt_4 > 0):
    cnt_2 = cnt_2 + cnt_4
    cnt_1 = cnt_1 + cnt_4
    cnt_4 = 0

i = 0
while(cnt_2 > 0 and i < k):
    tmp = int(arr[i] / 2)
    if(tmp > 0 and cnt_2 > 0):
        arr[i] = arr[i] - 2 * min(tmp, cnt_2)
        cnt_2 = cnt_2 - min(tmp, cnt_2)
    i = i + 1

if(cnt_2 > 0):
    cnt_1 = cnt_1 + cnt_2
    cnt_2 = 0

i = 0
while(i < k):
    tmp = arr[i]
    if(tmp > cnt_1):
        print("NO")
        return
    elif(tmp > 0 and tmp <= cnt_1):
        cnt_1 = cnt_1 - tmp
        arr[i] = arr[i] - tmp
    i = i + 1

print("YES")


"""
    Author      : Arif Ahmad
    Date        : 
    Algo        : 
    Difficulty  : 
"""
from sys import stdin, stdout

def main():
    n, k = [int(_) for _ in stdin.readline().strip().split()]
    a = [int(_) for _ in stdin.readline().strip().split()]

    cornerSlot = 2 * n
    middleSlot = 2 * n
    slotForOne = 0
    single = 0
    for x in a:
        req = x // 2
        #print('corner:', cornerSlot, ' middle:', middleSlot, ' single:', slotForOne)
        #print('group of:', x, ' req:', req, '\n')
        
        if req % 2 == 1:
            hand = 1
            req -= 1
        else:
            hand = 0

        # try to accommodate even no. of pairs in middle 
        if middleSlot >= req:
            middleSlot -= req
            req = 0
        elif middleSlot > 0 and req > middleSlot:
            req -= middleSlot
            middleSlot = 0

        if hand: req += 1

        # now accommodate rest of the pairs in the corner
        if cornerSlot >= req:
            cornerSlot -= req
            req = 0
        elif cornerSlot > 0 and req > cornerSlot:
            req -= cornerSlot
            cornerSlot = 0            
            
        # again, accommodate rest of the pairs in middle
        pairInMiddle = False
        if middleSlot >= req and (req > 0):
            middleSlot -= req
            req = 0
            pairInMiddle = True
        elif middleSlot > 0 and req > middleSlot:
            req -= middleSlot
            middleSlot = 0
            pairInMiddle = True
            
        if middleSlot % 2 == 1 and pairInMiddle:
            middleSlot -= 1
            slotForOne += 1

        #print('req now:', req)
        if x % 2 == 1: single += 1
        if req > 0: single += (req * 2)

        if single > 0:
            if slotForOne >= single:
                slotForOne -= single
                single = 0
            elif slotForOne > 0:
                single -= slotForOne
                slotForOne = 0

    total = cornerSlot + middleSlot
    while single > 0 and total > 0:
        total -= 1
        single -= 1

    if single: ans = 'NO'
    else: ans = 'YES' 
    stdout.write(ans)



def __starting_point():
    main()

__starting_point()

N,K = list(map(int,input().split()))
a = [int(i) for i in input().split()]
N = {4:N,3:0,2:N*2,1:0}

works = True
a.sort(reverse=True)

for i in range(K):
    r4 = min(N[4],a[i]//4)
    a[i]-=4*r4
    N[4]-=r4

a.sort(reverse = True)
#print(a,N)
for i in range(K):
    if a[i]==0:
        continue
    r2 = min(N[2],a[i]//2)
    a[i]-=2*r2
    N[2]-=r2

a.sort(reverse = True)
#print(a,N)
for i in range(K):
    #print("a",a,N,a[i])
    if a[i]==0:
        continue
    if a[i]>=4:
        works = False
        break
    #print("x")
    if a[i]==3:
        #print(" ai is 3")
        x = min(N[4],1)
        a[i]-=3*x
        N[4]-=x
        
    elif a[i]==2:
        #print( "ai is 2")
        x = min(N[2],a[i]//2)
        a[i]-=2*x
        N[2]-=x
        
        x = min(N[4],a[i]//2)
        a[i]-=2*x
        N[4]-=x
        N[1]+=x

        x = min(N[1],a[i])
        a[i]-=x
        N[1]-=x

    elif a[i]==1:
        #print(" ai is 1")
        N[1]+=N[2]
        N[1]+=2*N[4]
        N[4] = 0
        N[2]=0
        
        x = min(N[1],a[i])
        a[i]-=x
        N[1]-=x
   
    if a[i]!=0:
        #print(a[i])
        works = False
        break


if works:
    print("YES")
else:
    print("NO")


n, k = map(int, input().split())

a = list(map(int, input().split()))

c = [0, 0, 0, 0]

for t in a:
    c[0] += t//4
    if t%4: c[t%4] += 1

c[0] += c[3]
c[3] = 0

if c[0] > n:
    c[2] += 2*(c[0]-n)
    c[0] = n

t = min(n-c[0], c[1], c[2])
c[0] += t
c[1] -= t
c[2] -= t

t = min(n-c[0], (c[1]+1)//2)
c[0] += t
c[1] -= min(c[1], t*2)

t = min(n-c[0], c[2])
c[0] += t
c[2] -= min(c[2], t+t//2)

c[2] += c[1]
c[1] = 0

print("YES" if c[2] <= 2*n else "NO")

import heapq
rows, groups = list(map(int,input().split()))
counts = list([(-1)*int(x) for x in input().split()])

fours = rows
twos = 2*rows
ones = 0

f = True
heapq.heapify(counts)
while fours+twos+ones>0 and len(counts)>0:
    i = heapq.heappop(counts)
    i = i * (-1)
    if fours >= 1:
        if i < 4:
            twos+=fours
            ones+=fours
            fours = 0
            heapq.heappush(counts, i*(-1))
        else:
            d, m = divmod(i, 4)
            if d > fours:
                i -= fours*4
                fours=0
                if i>0:
                    heapq.heappush(counts, i*(-1))
            else:
                i -= d*4
                fours -= d
                if i>0:
                    heapq.heappush(counts, i*(-1))
    elif twos >= 1:
        if i < 2:
            ones += twos
            twos = 0
            heapq.heappush(counts, i*(-1))
        else:
            d, m = divmod(i, 2)
            if d > twos:
                i -= twos*2
                twos = 0
                if i > 0:
                    heapq.heappush(counts, i*(-1))
            else:
                i -= d*2
                twos -= d
                if i > 0:
                    heapq.heappush(counts, i*(-1))
    elif ones >= 1:
        if i > ones:
            f=False
            break
        else:
            ones -= i
if len(counts) > 0 or f == False:
    print("NO")
else:
    print("YES")








debug = 0
read = lambda: map(int, input().split())
k, n = read()
a = list(read())
cnt4 = k
cnt2 = 2 * k
for i in range(n):
    cnt = min(cnt4, a[i] // 4)
    a[i] -= cnt * 4
    cnt4 -= cnt
if debug: print(*a)
for i in range(n):
    cnt = min(cnt2, a[i] // 2)
    a[i] -= cnt * 2
    cnt2 -= cnt
if debug: print(' '.join(map(str, a)), ' ', cnt2, cnt4)
c = [0] * 20
for i in a:
    c[min(i, 19)] += 1
if debug:
    print(cnt2, cnt4, c)
d = min(cnt4, c[3])
c[3] -= d
cnt4 -= d
d = min(cnt4, c[1], c[2])
c[1] -= d
c[2] -= d
cnt4 -= d
d = min(cnt2, c[2])
c[2] -= d
cnt2 -= d
d = min(cnt2, c[1])
c[1] -= d
cnt2 -= d
d = min(cnt4, (c[2] + 2) // 3 + int(c[2] > 1))
c[2] -= d + d // 2
cnt4 -= d
if debug:
    print('cnt4 = ', cnt4)
    print('c[1] = ', c[1])
d = min(cnt4, c[2])
c[2] -= d
cnt4 -= d
d = min(cnt4, (c[1] + 1) // 2)
c[1] -= d * 2
cnt4 -= d
d = min(cnt4, c[1])
c[1] -= d
cnt4 -= d
print('YES' if sum(c[1:]) == 0 else 'NO')

read = lambda: map(int, input().split())
k, n = read()
a = list(read())
cnt4 = k
cnt2 = 2 * k
for i in range(n):
    cnt = min(cnt4, a[i] // 4)
    a[i] -= cnt * 4
    cnt4 -= cnt
for i in range(n):
    cnt = min(cnt2, a[i] // 2)
    a[i] -= cnt * 2
    cnt2 -= cnt
c = [0] * 20
for i in a:
    c[min(i, 19)] += 1
d = min(cnt4, c[3])
c[3] -= d
cnt4 -= d
d = min(cnt4, c[1], c[2])
c[1] -= d
c[2] -= d
cnt4 -= d
d = min(cnt2, c[2])
c[2] -= d
cnt2 -= d
d = min(cnt2, c[1])
c[1] -= d
cnt2 -= d
d = min(cnt4, (c[2] + 2) // 3 + int(c[2] > 1))
c[2] -= d + d // 2
cnt4 -= d
d = min(cnt4, c[2])
c[2] -= d
cnt4 -= d
d = min(cnt4, (c[1] + 1) // 2)
c[1] -= d * 2
cnt4 -= d
d = min(cnt4, c[1])
c[1] -= d
cnt4 -= d
print('YES' if sum(c[1:]) == 0 else 'NO')

n, k = map(int, input().split())

l = [0, 0, 2 * n, 0, n]

inp = sorted(map(int, input().split()), reverse = True)

for i in range(k):
	if inp[i] > 1 and inp[i] & 1:
		inp[i] -= 1
		inp.append(1)

for a in inp:
	if a == 1:
		if l[1]:
			l[1] -= 1
			a = 0
		elif l[2]:
			l[2] -= 1
			a = 0
		elif l[4]:
			l[4] -= 1
			l[2] += 1
			a = 0
	else:	
		while a > 2 and l[4]:
			a -= 4
			l[4] -= 1
		while a and l[2]:
			a -= 2
			l[2] -= 1
		while a and l[4]:
			a -= 2
			l[4] -= 1
			l[1] += 1
		while a and l[1]:
			a -= 1
			l[1] -= 1

	if a:
		print('NO')
		return

print('YES')

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a1 = 0
a2 = 2 * n
a4 = n
flag = True
s1 = 0
s2 = 0
for x in a:
    while x >= 3:
        if a4:
            a4 -= 1
            x -= 4
        elif a2 > 1:
            a2 -= 1
            x -= 2
        else:
            flag = False
            break
    if not flag:
        break
    if x == 2:
        s2 += 1
    elif x == 1:
        s1 += 1
#print(s1, s2, a1, a2, a4)
while s2:
    if a2:
        a2 -= 1
        s2 -= 1
    elif a4:
        a4 -= 1
        a1 += 1
        s2 -= 1
    else:
        s1 += 2
        s2 -= 1
print("YES" if flag and a1 + a2 + a4 * 2 >= s1 else "NO")



n,k = list(map(int, input().split()))

a = list(map(int,input().split()))
all_sum = sum(a)
r4,r2 = n,n*2
for v in range(len(a)):
	mid = a[v] // 4
	a[v] = a[v] % 4
	if mid <= r4:
		r4 -= mid
	else:
		a[v] += 4 * (mid - r4)
		r4 = 0
	if r4 == 0:
		break
mid = 0
r22 = 0
for v in a:
	if v % 2 == 1:
		mid += 1
	r22 += v // 2
#print(r4,r22,mid,r2)
if r4 > 0:
	mid -=r4
	r22 -= r4
	if mid < 0:
		r22 -= (mid // -2)
		mid = 0

if r22 + mid > r2:
	print('NO')
else:
	print('YES')







n,k = list(map(int, input().split()))

a = list(map(int,input().split()))
all_sum = sum(a)
r4,r2 = n,n*2
for v in range(len(a)):
	mid = a[v] // 4
	a[v] = a[v] % 4
	if mid <= r4:
		r4 -= mid
	else:
		a[v] += 4 * (mid - r4)
		r4 = 0
	if r4 == 0:
		break
mid = 0
r22 = 0
for v in a:
	if v % 2 == 1:
		mid += 1
	r22 += v // 2
#print(r4,r22,mid,r2)
if r4 > 0:
	mid -=r4
	r22 -= r4
	if mid < 0:
		r22 -= (mid // -2)
		mid = 0

if r22 + mid > r2:
	print('NO')
else:
	print('YES')







import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))

mid = n
side = n*2

def removeZeroes(a):
    return [x for x in a if x > 0]

#FOR 4 
for i in range(len(a)):
    if a[i] >= 4:
        while a[i] >= 4 and (mid > 0 or side > 1):
            a[i] -= 4
            if mid:
                mid -= 1
            else:
                side -= 2

#FOR 3
for i in range(len(a)):
    if not(mid > 0 or side > 1): 
        break
    if a[i] == 3:
        if mid > 0:
            mid -= 1
        else:
            side -= 2
        a[i] = 0
            
#REMOVE GROUPS WITH 0 REMAINED
a = removeZeroes(a)

if a.count(2) + a.count(1) != len(a):
    print("NO")
    return

for i in range(len(a)):
    if a[i] == 2 and side > 0:
        side -= 1
        a[i] = 0

for i in range(len(a)):
    if a[i] == 1 and side > 0:
        side -= 1
        a[i] = 0

a = removeZeroes(a)
a.sort()
while len(a) > 0 and a[0] == 1 and a[-1] == 2 and mid > 0:
    a = a[1:-1]
    mid -= 1
if len(a) > 0 and a[0] == 1:
    if (a.count(1)+1) // 2 <= mid:
        print("YES")
        return
    else:
        print("NO")
        return
elif len(a) > 0 and a[0] == 2:
    while len(a) > 2 and mid > 1:
        a = a[3:]
        mid -= 2
    if mid >= len(a):
        print("YES")
        return

if len(a) > 0:
    print("NO")
else:
    print("YES")

n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
s2=n*2
s4=n
s1=0
f=1
rem1=0
rem2=0
for i in range(len(a)):
    if(f):
        while(a[i]>=3):
            if(s4>0):
                a[i]-=4
                s4-=1
            elif(s2>0):
                a[i]-=2
                s2-=1
            else:
                f=0
        if(a[i]==1 and f):
            rem1+=1
        elif(a[i]==2 and f):
            rem2+=1
while(rem2>0 and f):
    if(s2>0):
        rem2-=1
        s2-=1
    elif(s4>0):
        rem2-=1
        s4-=1
        s1+=1
    else:
        rem2-=1
        rem1+=2
if(rem1>s1+s2+s4*2):
    f=0
if(f):
    print('YES')
else:
    print('NO')


n, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))[::-1]
m = n
for j in range(len(a)):
  waste = min(a[j] // 4, m)
  m -= waste
  a[j] -= waste * 4
  if m == 0:
    break
m1, m2, m3, msukabljat = 0, 0, 0, []
for x in a:
  m1 += (x == 1)
  m2 += (x == 2)
  m3 += (x == 3)
  msukabljat += ([x] if x >= 4 else [])
waste = min(m1, m2, m)
m, m1, m2 = m - waste, m1 - waste, m2 - waste
waste = min(m3 // 2, m // 2)
m, m3 = m - waste * 2, m3 - waste * 2
waste = min(m2 // 3, m // 2)
m, m2 = m - waste * 2, m2 - waste * 3
waste = min(m1, m2, m3, m // 2)
m, m1, m2, m3 = m - waste * 2, m1 - waste, m2 - waste, m3 - waste
waste = min(m3, m)
m, m3 = m - waste, m3 - waste
waste = min(m1 // 2, m)
m, m1 = m - waste, m1 - 2 * waste
waste = min(m1, m)
m, m1 = m - waste, m1 - waste
waste = min(m2, m)
m, m2 = m - waste, m2 - waste
if m1 + m2 + m3 * 2 + sum([x // 2 + x % 2 for x in msukabljat]) <= 2 * n:
  print("YES")
else:
  print("NO")



n, k = map(int, input().split())

l = list(map(int, input().split()))

l = sorted(l, reverse=True)
s = 0
for _ in range(n):
    if l[0] <= 0:
        break
    if l[0] <= 2:
        l[0] -= min(l[0],2)
        s += 1
    l[0] -= min(l[0],4)
    l = sorted(l, reverse=True)
for _ in range(n):
    if l[0] <= 0:
        break
    l[0] -= min(l[0],2)
    l = sorted(l, reverse=True)
for _ in range(n):
    if l[0] <= 0:
        break
    l[0] -= min(l[0],2)
    l = sorted(l, reverse=True)
for _ in range(s):
    if l[0] <= 0:
        break
    l[0] -= min(l[0],1)
    l = sorted(l, reverse=True)


if l[0] <= 0:
    print("YES")
else:
    print("NO")

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

left4seat = n
left2seat = n * 2
left1seat = 0
for i in range (0, k) :
	left4seat -= a[i] // 4
	if (left4seat < 0) :
		left2seat += 2 * left4seat
		left4seat = 0

index = 0
while (index < k ) :
	leftSol = a[index] % 4
	if (leftSol == 3) : 
		if (left4seat > 0) : left4seat -= 1
		else : 
			if (left1seat > 0) :
				if (left2seat == 0 and left1seat >= 2) : left1seat -= 3
				else:
					left2seat -= 1
					left1seat -= 1
			else :
				left2seat -= 2
	elif (leftSol == 2) :
		if (left4seat > 0) : 
			left4seat -= 1
			left1seat += 1
		else : 
			if (left2seat == 0 and left1seat >= 2) : left1seat -= 2
			else : left2seat -= 1
	elif (leftSol == 1) :
		if (left1seat > 0) : left1seat -= 1
		elif (left4seat > 0) : 
			left4seat -= 1
			left2seat += 1
		else : 
			left2seat -= 1
	if (left4seat < 0 or left2seat < 0) : break
	index += 1

if (index == k and left4seat >= 0 and left2seat >= 0) : print("YES")
else : print("NO")