Problem:
 Score : 400 points    Problem Statement We have a sequence of length N , a = (a_1, a_2, ..., a_N) .
Each a_i is a positive integer.  Snuke's objective is to permute the element in a so that the following condition is satisfied:   For each 1 ≤ i ≤ N - 1 , the product of a_i and a_{i + 1} is a multiple of 4 .   Determine whether Snuke can achieve his objective.      Constraints  2 ≤ N ≤ 10^5  a_i is an integer.  1 ≤ a_i ≤ 10^9         Input Input is given from Standard Input in the following format:  N  a_1  a_2  ...  a_N       Output If Snuke can achieve his objective, print Yes ; otherwise, print No .        Sample Input 1 3
1 10 100      Sample Output 1 Yes  One solution is (1, 100, 10) .       Sample Input 2 4
1 2 3 4      Sample Output 2 No  It is impossible to permute a so that the condition is satisfied.       Sample Input 3 3
1 4 1      Sample Output 3 Yes  The condition is already satisfied initially.       Sample Input 4 2
1 1      Sample Output 4 No       Sample Input 5 6
2 7 1 8 2 8      Sample Output 5 Yes

Solution (Python):
from collections import defaultdict
def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for i in range(N):
        if A[i] % 2 == 0:
            if A[i] % 4 == 0:
                d[2] += 1
            else:
                d[1] += 1
        else:
            d[0] += 1
    
    if d[1] == 0:
        if d[0] - 1 <= d[2]:
            print('Yes')
            exit()
    else:
        if d[0] <= d[2]:
            print('Yes')
            exit()

    print('No')

    


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
A = list(map(int, input().split()))

odd=0
even=0
even2=0

for num in A:
    if(num%2==1):
        odd+=1
    elif(num%4==0):
        even2+=1
    else:
        even+=1

if(even2>=odd):
    print("Yes")
elif((even==0)&(even2==(odd-1))):
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a = list(map(int,input().split()))
for i in range(n):
    cnt=0
    while a[i]%2==0:
        a[i]=a[i]//2
        cnt+=1
    a[i]=cnt
x=y=0
for i in range(n):
    if a[i]==0:
        x+=1
    elif a[i]>1:
        y+=1
if len(a)%2==1:
    if x > y+1:
        print("No")
    else:
        print("Yes")
elif len(a)%2==0:
    if x > y:
        print("No")
    else:
        print("Yes")

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
odd=len([1 for i in l if i%2])
t4=len([1 for i in l if i%4==0])
if odd+t4==n:
  if odd-1<=t4:print("Yes")
  else:print("No")
elif odd<=t4:print("Yes")
else:print("No")

Solution (Python):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    odd = even = even4 = 0
    for a in A:
        if a % 4 == 0:
            even4 += 1
        elif a % 2 == 0:
            even += 1
        else:
            odd += 1
    if even == 0:
        print("Yes" if even4 >= odd - 1 else "No")
    else:
        print("Yes" if even4 >= odd else "No")


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
l=m=n=0
for i in a:
  if i%4==0:
    l+=1
  elif i%2==0:
    m+=1
  else:
    n+=1
if l>=n or (m==0 and l+1>=n):
  print("Yes")
else:
  print("No")

Solution (Python):
N=int(input())
A=list(map(int,input().split()))

b2=0
b4=0
bb=0
for a in A:
  if a%4==0:
    b4+=1
  if a%2==0:
    b2+=1
bb=N-b2
b2-=b4


if b2==0:
  if b4+1>=bb:
    print("Yes")
  else:
    print("No")
else:
  if b4>=bb:
    print("Yes")
  else:
    print("No")

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = list(map(int,input().split()))
    
    one = 0
    two = 0
    four = 0
    for i in A:
        if i%4==0:
            four += 1
        elif i%2==0:
            two += 1
        else:
            one += 1
            
    if two == 0:
        if four+1 >= one:
            print("Yes")
        else:
            print("No")
    else:
        if four >= one:
            print("Yes")
        else:
            print("No")
    
    
main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
div_4 = 0
div_2 = 0
div_0 = 0
for a in A:
    tmp = a
    count = 0
    while True:
        if tmp % 2 == 0:
            tmp = tmp // 2
            count += 1
        else:
            break
    if count == 0:
        div_0 += 1
    elif count == 1:
        div_2 += 1
    else:
        div_4 += 1
if div_2 == 0:
    if div_0 <= (div_4 + 1):
        print("Yes")
    else:
        print("No")
else:
    if div_0 <= div_4:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  two = 0
  four = 0
  for i in a:
    if i %4 == 0:
      four += 1
    elif i%2 == 0:
      two += 1
  four += two//2
  if n <= four*2+1:
    print("Yes")
  else:
    print("No")
solve()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))

f=True
c=0
o=0
ans="No"
for i in range(N):
    if a[i]%2!=0:
        f=False
        o+=1
    if a[i]%4==0:
        c+=1

if f:
    ans="Yes"
if c>=o or c>=N//2:
    ans="Yes"

print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))

f=True
c=0
o=0

for i in range(N):
    if a[i]%2!=0:
        f=False
        o+=1
    if a[i]%4==0:
        c+=1

if f:
    print("Yes")
    exit()
if c>=o:
    print("Yes")
    exit()
if c>=N//2:
    print("Yes")
    exit()

print("No")

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans="No"
f=[a for a in A if a%4==0]
t=[a for a in A if a%4!=0 and a%2==0]
if len(f)*2+len(t)>=N:
  ans="Yes"
elif len(f)>=(N-1)//3+1 and N%2!=0:
  ans="Yes"
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

odd = 0
mul4 = 0

for a in A:
    if a % 2 != 0:
        odd += 1
    if a % 4 == 0:
        mul4 += 1

if mul4 >= odd:
    print('Yes')
else:
    if mul4 * 2 + 1 == N:
        print('Yes')
    else:
        print('No')

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
four = len([a for a in A if a%4==0])
even = len([a for a in A if a%4!=0 and a%2==0])
if N-(four*2)<=even or four>=N//2:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
m1, m2, m4 = 0, 0, 0

for a in input().split():
    x = int(a)
    if x % 2 == 0:
        if x % 4 == 0: m4 += 1
        else: m2 += 1
    else: m1 += 1

ans = m4 >= m1 if(m2) else m4 + 1 >= m1
print("Yes" if ans else "No")

Solution (Python):

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    f, t, m = 0, 0, 0  
    for i in A:
        if i % 4 == 0:
            f += 1
        elif i % 2 == 0:
            t += 1
        else:
            m += 1
    m += t % 2
    flg = f + 1 >= m
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
two_ad = 0
four_ad = 0
other = 0
for a in A:
  if a % 4 == 0:
    four_ad += 1
  elif a % 2 == 0:
    two_ad += 1
  else:
    other += 1

ans = "No"
if four_ad >= other:
  ans = "Yes"
elif four_ad == other - 1 and not two_ad:
  ans = "Yes"
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
two_ad = 0
four_ad = 0
other = 0
for a in A:
  if a % 4 == 0:
    four_ad += 1
  elif a % 2 == 0:
    two_ad += 1
  else:
    other += 1

ans = "No"
if four_ad >= other:
  ans = "Yes"
elif four_ad == other - 1 and not two_ad:
  ans = "Yes"
print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return


def B():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y,su):
        x = root(x)
        y = root(y)
        su += comb_2(s[x])+comb_2(s[y])
        if rank[x] < rank[y]:
            s[y] += s[x]
            su -= comb_2(s[y])
            par[x] = y
        else:
            s[x] += s[y]
            su -= comb_2(s[x])
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return su

    def comb_2(a):
        return a*(a-1)//2

    n,m = LI()
    v = LIR(m)
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = comb_2(n)
    ans = [su]
    for a,b in v[:0:-1]:
        a -= 1
        b -= 1
        if root(a) != root(b):
            su = unite(a,b,su)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return


def C():
    def root(x):
        if par[x] == x:
            return par[x]
        r = root(par[x])
        d[x] += d[par[x]]
        par[x] = r
        return par[x]

    def weight(x):
        root(x)
        return d[x]

    def unite(x,y,w):
        w += weight(x)
        w -= weight(y)
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            d[x] = -w
        else:
            par[y] = x
            d[y] = w
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    d = [0]*n
    for i in range(m):
        l,r,w = LI()
        l -= 1
        r -= 1
        if root(l) != root(r):
            unite(l,r,w)
        else:
            if weight(r)-weight(l) != w:
                print("No")
                return
    print("Yes")
    return


def D():
    h,w = LI()
    n = I()
    a = LI()
    ans = [0]*h*w
    p = 0
    for i in range(n):
        for j in range(a[i]):
            ans[p+j] = i+1
        p += a[i]
    for i in range(h):
        s = ans[i*w:(i+1)*w]
        if i%2:
            print(*s[::-1])
        else:
            print(*s)
    return


def E():
    n,k = LI()
    s = [int(x) for x in input()]
    f = [0]*n
    j = 0
    su = 1
    p = s[0]
    for i in range(1,n):
        if s[i] != p:
            f[j] = su
            j += 1
            su = 1
            p = s[i]
        else:
            su += 1
    f[j] = su
    f.append(0)
    if s[0]:
        m = sum(f[:2*k+1])
        ans = m
        for i in range(2*k+1,n):
            m -= f[i-2*k-1]
            if not i%2:
                m += f[i-1]
                m += f[i]
            ans = max(m,ans)
    else:
        m = sum(f[:2*k])
        ans = m
        for i in range(2*k,n):
            m -= f[i-2*k]
            if not i%2:
                m += f[i]
                m += f[i+1]
            ans = max(m,ans)
    print(ans)
    return


def F():
    n = I()
    a = LI()
    s = [0,0,0]
    for i in a:
        if i%4 == 0:
            s[0] += 1
        elif i%2 == 0:
            s[1] += 1
        else:
            s[2] += 1
    a = [0]
    while 1:
        if s[2]:
            if a[-1] == 2:
                print("No")
                return
            s[2] -= 1
            a.append(2)
            if s[0]:
                s[0] -= 1
                a.append(0)
        elif s[1]:
            if a[-1] == 2:
                print("No")
            else:
                print("Yes")
            return
        else:
            print("Yes")
            return
    return


def G():

    return


def H():

    return


def I_():

    return


if __name__ == "__main__":
    F()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

four_divisible = 0
odd = 0
for e in a:
    if e % 2 != 0:
        odd += 1
    elif e % 4 == 0:
        four_divisible += 1
    
if odd > four_divisible:
    if odd == four_divisible + 1 and odd + four_divisible == N:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def count2(n):
    
    ret = 0
    while n & 1 == 0:
        n >>= 1
        ret += 1
    return ret


C = list(map(count2, A))
C.sort()
C = deque(C)

order = []
while C:
    order.append(C.popleft())
    if C:
        order.append(C.pop())
ok = True
for a, b in zip(order[:-1], order[1:]):
    ok &= a + b >= 2
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):


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

sec=0
quad=0
rem=0
for i in range(n):
    if a[i]%4==0:
        quad+=1
    elif a[i]%2==0:
        sec+=1
    else:
        rem+=1

if sec>0:rem+=1
if rem-quad<=1:
    print('Yes')
else:print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
t1=0
t2=0
t4=0
for i in a:
    if i%4==0:
        t4+=1
    elif i%2==0:
        t2+=1
    else:
        t1+=1
if t2==0:
    print('Yes' if t1<=t4+1 else 'No')
else:
    print('Yes' if t1<=t4 else 'No')

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
tmp,tmp2,two = 0,0,0
for a in A:
    if a%4 == 0: tmp += 1
    elif a%2 == 0: two = 1
    else: tmp2 += 1

if tmp2+two-tmp >= 2: print('No')
else: print('Yes')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, a: "List[int]"):
    count = [0 for _ in range(4)]
    for x in a:
        count[x % 4] += 1
    
    M = N - max(0, count[2] - 1)
    if count[0] >= M // 2:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
o=0;f=0
x='Yes'
for i in a:
  if i%4==0:
    f+=1
  elif i%2==1:
    o+=1
if o>f:
  if o!=f+1 or o+f!=n:
    x='No'
print(x)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
F = [0,0,0]
for a in A:
    if a%4==0: F[2]+=1
    elif a%2==0: F[1]+=1
    else: F[0]+=1
ans = "Yes"
if F[0]==F[2]+1 and F[1]>0: ans="No"
if F[0]>F[2]+1: ans="No"
print(ans)

Solution (Python):
n=int(input())
a=list(map(lambda x:int(x)%4,input().split()))
for i,j in enumerate(a):
	if j==0:
		a[i]=2
	elif j==2:
		a[i]=1
	else:
		a[i]=0
if sum(a)<(n//2)*2:
	print('No')
else:
	print('Yes')

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
c=[0]*3
for n in A:
    if n%4==0:
        c[0]+=1
    elif n%2==0:
        c[1]+=1
    else:
        c[2]+=1
a=(c[2]==0 or c[0]>=c[2] or (c[1]==0 and c[2]==c[0]+1))
print(['No','Yes'][a])

Solution (Python):
n = int(input())
a = list(map(int,input().split()))


four = 0
two = 0
odd = 0

for x in a:
    if x%4 == 0:
        four += 1
    elif x%2 == 0:
        two += 1
    else:
        odd += 1


ans = 0
if two == 0 and odd - four == 1:
    ans = 0
else:
    if odd > four:
        ans = 1
if ans == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    f, t, m = 0, 0, 0  
    for i in A:
        if i % 4 == 0:
            f += 1
        elif i % 2 == 0:
            t += 1
        else:
            m += 1
    m += t % 2
    print("Yes" if m - f <= 1 else "No")


if __name__ == "__main__":
    main()

Solution (Python):
n,a=open(0)
c=[int(i)%4for i in a.split()].count
f,g=c(0),c(2)
print('YNeos'[int(n)-f-g>f+(g==0)::2])

Solution (Python):
n,a=open(0)
c=[int(i)%4for i in a.split()].count
f,g=c(0),c(2)
print('YNeos'[int(n)-f-g>f+(g==0)::2])

Solution (Python):
n,a=open(0)
a=[int(i)%4for i in a.split()]
f,g=a.count(0),a.count(2)
print('YNeos'[int(n)-f-g>f+(g==0)::2])

Solution (Python):
n = int(input())
an = list(map(int,input().split()))
four = 0
odd = 0
for a in an:
    if a%4==0:
        four+=1
    if a%2!=0:
        odd+=1
if odd+four!=n:
    odd+=1
if four >= odd - 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
four,two,one=0,0,0
for a in map(int,input().split()):
    if a%4==0:
        four+=1
    elif a%2==0:
        two+=1
    else:
        one+=1
if two==0:
    if four+1>=one:
        print('Yes')
    else:
        print('No')
else:
    if four>=one:
        print('Yes')
    else:
        print('No')

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
cnt_4 = 0
cnt_1 = 0
for i in range(n):
    if a[i] % 4 == 0:
        cnt_4 += 1
    elif a[i] % 2 == 0:
        pass
    else:
        cnt_1 += 1
if cnt_4 >= cnt_1:
    print("Yes")
elif cnt_4 + cnt_1 == n and cnt_4 >= cnt_1-1:
    print("Yes")
else:
    print("No")

Solution (Python):


n = int(input())
arr = list(map(int, input().split()))
dividable_four = 0
odds = 0
for a in arr:
    if a % 4 == 0:
        dividable_four += 1
    elif a % 2 == 1:
        odds += 1
if dividable_four >= odds:
    print('Yes')
elif odds - dividable_four == 1 and odds + dividable_four == n:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = list(map(int,input().split()))

ans = 'No'

cnt4 = 0
cnt2 = 0

for aa in a:
    if aa%4 == 0:
        cnt4 += 1
    elif aa%4 == 2:
        cnt2 += 1

if 2*cnt4 + 1 >= N:
    ans = 'Yes'
else:
    res = N - 2*cnt4
    if res <= cnt2:
        ans = 'Yes'
        
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
c_odd = 0
c_even = 0
c_4 = 0

for i in range(N):
    if a[i] % 2 != 0:
        c_odd += 1
    else:
        if a[i] % 4 == 0:
            c_4 += 1
        else:
            c_even += 1

if c_even == 0:
    if c_odd <= c_4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if c_odd == c_4:
        print('Yes')
    else:
        print('No')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

f_cnt = 0
t_cnt = 0
o_cnt = 0
for _a in a:
    if _a % 4 == 0:
        f_cnt += 1
    elif _a % 2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if o_cnt == 0:
    print("Yes")
elif o_cnt < f_cnt+1:
    print("Yes")
elif o_cnt == f_cnt + 1 and t_cnt == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

i=0
j=0
s=[]
c=0
while i!=n:
    x=a[i]

    while j!=2:
        if x%2==0 and 2<=x:

            c+=1
            x=x/2
            j+=1
        else:
            break

    s.append(c)
    c=0
    j=0
    i+=1
if s.count(2)>s.count(0):
    print("Yes")
elif (s.count(0)-s.count(2))>1:
    print("No")
elif s.count(0)==s.count(2):
    print("Yes")
elif s.count(0)+s.count(2)==len(s):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

num = 0
num2 = 0
num4 = 0

for i in a:
    if i % 4 == 0:
        num4 += 1
    elif i % 2 == 0:
        num2 += 1
    else:
        num += 1
num2 %= 2
num += num2
if num4 + 1 >= num:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
nums=list(map(int,input().split()))
mods=[]
for i in range(n):
  cnt=0
  while nums[i]%2==0:
    nums[i]//=2
    cnt+=1
  mods.append(cnt)
count2=sum(1 for i in mods if i>=2)
count0=sum(1 for i in mods if i==0)
if count2+count0==len(mods):
  if count2>=count0-1:
    print("Yes")
  else:
    print("No")
else:
  if count2>=count0:
    print("Yes")
  else:
    print("No")

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

odd = 0
ml2 = 0
ml4 = 0

for ai in a:
    if ai % 2:
        odd += 1
    elif ai % 4:
        ml2 = 1
    else:
        ml4 += 1

print("Yes" if (odd + ml2) <= (ml4 + 1) else "No")

Solution (Python):
N=int(input())
one,two,four=0,0,0
for a in map(int,input().split()):
    if a%4==0:
        four+=1
    elif a%2==0:
        two+=1
    else:
        one+=1
if two==0:
    if one<=four+1:
        print('Yes')
    else:
        print('No')
else:
    if one<=four:
        print('Yes')
    else:
        print('No')

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
two=0
one=0
four=0
for a in A:
    if a%4==0:
        four+=1
    elif a%2==0:
        two+=1
    else:
        one+=1
if two==0 and one<=four+1:
    print('Yes')
elif one<=four:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
A = map(int, input().split())

fac_2 = 0
fac_4 = 0
for a in A:
    if a % 4 == 0:
        fac_4 += 1
    elif a % 2 == 0:
        fac_2 += 1

if fac_2 == 0:
    x = 1
else:
    x = 0

if fac_2 + fac_4*2 + x >= N:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
aa = [2 if i % 4 == 0 else 1 if i % 2 == 0 else 0 for i in a]
a4, a2, a0 = aa.count(2),aa.count(1), aa.count(0)

if a2 == 0:
    a4 += 1

print("Yes" if a4 >= a0 else "No")

Solution (Python):
a = int(input())
l = list(map(int,input().split()))

b = sum((i % 2 != 0)  for i in l)
bb = sum((i % 2 == 0)  for i in l)
bbbb  = sum((i % 4 == 0)  for i in l)

bb -= bbbb
if bbbb+1 >= b + (bb != 0):print("Yes")
else:print("No")

Solution (Python):
a = int(input())
l = list(map(int,input().split()))

b = sum((i % 2 != 0)  for i in l)
bb = sum((i % 2 == 0)  for i in l)
bbbb  = sum((i % 4 == 0)  for i in l)

bb -= bbbb
if bbbb+1 >= b + (bb != 0):print("Yes")
else:print("No")

Solution (Python):
N = int(input())
li = map(int,input().split())

g1=0
g2=0
g4=0
for v in li:
  if (v%4==0):
    g4+=1
  elif (v%2==0):
    g2+=1
  else:
    g1+=1
flag = True
if ( g2>0 and g4<g1):
  flag = False
if ( g2==0 and g4+1<g1):
  flag = False
print ( "Yes" if flag else "No" )

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

n1, n2, n4 = 0, 0, 0
for a in A:
	if not a % 4:
		n4 += 1
	elif not a % 2:
		n2 = 1
	else:
		n1 += 1


print(["Yes", "No"][not(n1 + n2 <= n4 + 1)])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

n1, n2, n4 = 0, 0, 0
for a in A:
	if not a % 4:
		n4 += 1
	elif not a % 2:
		n2 += 1
	else:
		n1 += 1


print(["Yes", "No"][not(n1 + (n2 % 2) <= n4 + 1)])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
two, four = 0, 0
for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        two += 1
if two == 0:
    can = four * 2 + 1
else:
    can = four * 2 + two

if can >= N:
    print('Yes')
else:
    print('No')

Solution (Python):

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


X = sum(x % 2 == 1 for x in a)
Y = sum(x % 2 == 0 and x % 4 == 2 for x in a)
Z = sum(x % 4 == 0 for x in a)
ans = (
    'Yes' if X <= Z or X == Z + 1 and Y == 0 else
    'No'
)


print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
odd, nibai, yonbai = 0, 0, 0

for i in range(N):
    if A[i] % 2 != 0:
        odd += 1
    elif A[i] % 4 == 0:
        yonbai += 1
    else:
        nibai += 1

if nibai == 0:
    if odd > yonbai+1:
        print('No')
    else:
        print('Yes')
else:
    if odd > yonbai:
        print('No')
    else:
        print('Yes')

Solution (Python):
import math
N = int(input())
a = [int(x) for x in input().split()]
a4,a2 = 0,0

for x in a:
    if x % 4 == 0:  a4 += 1
    elif x % 2 == 0:    a2 += 1

if N//2 <= a4 or math.ceil((N-a2)/2) <= a4: print("Yes")
else:   print("No")

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
cnt4=0
cnt2=0
cnt1=0
for i in a:
    if(i%4==0):
        cnt4+=1
    elif(i%2==0):
        cnt2+=1
    else:
        cnt1+=1
n = cnt4+1-cnt1
if(n>=0 and cnt2==0):
    print('Yes')
elif(n>=1 and cnt2>=1):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

def a():
    N = int(input())
    A = map(int,input().split(" "))
    c = Counter(map(lambda x:(x%4 and 1)+x%2,A))
    if c[1]:
        return c[2] <= c[0]
    else:
        return c[2] <= c[0] + 1

print(['No','Yes'][a()])

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
m2=0
m1=0
m0=0
for a in A:
  if a%4==0:
    m2+=1
  elif a%2==0:
    m1+=1
  else:
    m0+=1
if m1==0:
  if m2-m0>=-1:
    print("Yes")
  else:
    print("No")
if m1!=0:
  if m2-m0>=0:
    print("Yes")
  else:
    print("No")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

odd = 0
single_even = 0
double_even = 0
for a in A:
  if a%2:
    odd += 1
  elif a%2==0 and a%4:
    single_even +=1
  else:
    double_even += 1
    
if (odd == double_even +1 and single_even%2==0) or (odd <= double_even):
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

c2 = 0
c4 = 0

for aa in a:
    if aa % 4 == 0:
        c4 += 1
    else:
        if aa % 2 == 0:
            c2 += 1

if c4 >= N // 2:
    print("Yes")
else:
    if N - c4 * 2 <= c2:
        print("Yes")
    else:
        print("No")

Solution (Python):
N=int(input())
A=[int(i)%4 for i in input().split()]
f,t=A.count(0),A.count(2)
print(["No","Yes"][N-f-t<=f+(t==0)])

Solution (Python):
N=int(input())
A=[int(i)%4 for i in input().split()]
f,t=A.count(0),A.count(2)
print(["No","Yes"][N-f-t<=f+(t == 0)])

Solution (Python):
N = int(input())
A = [int(i) % 4 for i in input().split()]

f, t = A.count(0), A.count(2)
if N - f - t <= f + (t == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

f, t = 0, 0
for a in A:
    if a % 4 == 0:
        f += 1
    elif a % 2 == 0:
        t += 1

if N - f - t <= f + (t == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

f, t, o = 0, 0, 0
for a in A:
    if a % 4 == 0:
        f += 1
    elif a % 2 == 0:
        t += 1
    else:
        o += 1

if o <= f + (t == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

def solve():
    f, t, o = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            f += 1
        elif a % 2 == 0:
            t += 1
        else:
            o += 1

    if t == 0:
        return (o <= f + 1)
    else:
        return (o <= f)

if solve():
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
C = Counter(4 if a % 4 == 0 else 2 if a % 2 == 0 else 1 for a in A)

if C[2] == 0:
    print("Yes" if C[1] <= C[4] + 1 else "No")
else:
    print("Yes" if C[1] <= C[4] else "No")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
a, b, c = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    a += 1
  elif A[i] % 2 == 0:
    b += 1
  else:
    c += 1

b = 1 if b > 0 else 0  
if b + c > a + 1:
  print('No')
else:
  print('Yes')

Solution (Python):
input()
d={0:0,1:0,2:0}
def cnt(i):i=int(i);d[0 if i%2 else(1 if i%4 else 2)]+=1
list(map(cnt,input().split()))
print("YNeos"[d[0]-d[2]>(d[1]==0)::2])

Solution (Python):
N=int(input())
d={0:0,1:0,2:0}
def cnt(i):
    i=int(i)
    d[0 if i%2 else(1 if i%4 else 2)]+=1
list(map(cnt,input().split()))
print((d[0]>d[2]and (d[0]+d[2]!=N or d[0]!=d[2]+1) if N%2 else d[0]>d[2]) and"No"or"Yes")

Solution (Python):
N = int(input())
T = list(map(int, input().split()))

counter = []
for i in range(N):
    if T[i] % 4 == 0:
        count = 2
    elif T[i] % 2 == 0:
        count = 1
    else:
        count = 0
    counter.append(count)

c0 = counter.count(0)
c1 = counter.count(1)
c2 = counter.count(2)

if c0 - 1 <= c2 and c1 % 2 == 0:
    print('Yes')
elif c0 <= c2:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))

four = 0
even = 0

for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        even += 1

if max(even-1,0) + 2*four >= N - 1:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
one = 0
four = 0
for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 1:
        one += 1

ans = 'No'
if one + four == N:
    if four + 1 >= one:
        ans = 'Yes'
else:
    if four >= one:
        ans = 'Yes'
print(ans)

Solution (Python):
from collections import Counter
from functools import reduce

import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    
    x = root(x)
    y = root(y)
    if x == y:
        return
    
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  
        return x
    else:
        node[x] = root(node[x])  
        return node[x]
def dfs(v):
    
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  
            continue
        if visited[v2] == True:  
            continue
        dfs(v2)

n = II()
a = LI()


two = sum(number % 2 == 0 and number % 4 != 0 for number in a)

four = sum(number % 4 == 0 for number in a)

if two % 2 == 1:
    print('Yes') if len(a) - two <= 2 * four else print('No')
else:
    print('Yes') if len(a) - two - 1 <= 2 * four else print('No')

Solution (Python):

N=int(input())
a=list(map(int,input().split()))
x=[]
k0=0
k1=0
k2=0

for i in range(N):
    if a[i]%4==0:
        x.append(2)
        k2+=1
    elif a[i]%4==2:
        x.append(1)
        k1+=1
    else:
        x.append(0)
        k0+=1


if (k1)%2==0:
    if k2+1>=k0:
        print("Yes")
    else:
        print("No")
else:
    if k2>=k0:
        print("Yes")
    else:
        print("No")