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):
N =int(input())
a = list(map(int,input().split()))
ki = 0
ni = 0
yon = 0
for i in range(N):
    if a[i]%2 == 1:
        ki += 1
    elif a[i]%4 != 0:
        ni += 1
    else: yon += 1
if ki+int(ni>0) <= yon+1:
    print("Yes")
else: print("No")

Solution (Python):
from sys import stdin
from itertools import groupby

point = 0

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

su4 = 0
su2 = 0
su = 0

for i in range(n):
    if li[i] % 4 == 0:
        su4 += 1
    elif li[i] % 2 == 0:
        su2 += 1
    else:
        su += 1
    
if su4+1 < su:
    print("No")
    exit()
if su2 % 2 == 0:
    print("Yes")
    exit()
else:
    if su4 -su >= 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

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

cnt2 = 0
cnt4 = 0
for i in range(n):
  if li[i]%4 == 0:
    cnt4 += 1
  elif li[i]%2 == 0:
    cnt2 += 1
if cnt2 == 0:
  if n//2 <= cnt4:
    print("Yes")
  else:
    print("No")
else:
  if 2*cnt4 + cnt2 >= n:
    print("Yes")
  else:
    print("No")

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    int(input())
    cnt=[0]*3
    for a in map(int,input().split()):
        if(a%4==0): cnt[2]+=1
        elif(a%2==0): cnt[1]+=1
        else: cnt[0]+=1
    if(cnt[1]): cnt[0]+=1
    print("Yes" if(cnt[2]>=cnt[0]-1) else "No")
resolve()

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

four = 0
two = 0
one = 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  elif A[i] % 2 == 0:
    two += 1
  else:
    one += 1
    
if four >= one:
  print("Yes")
elif (four + 1 == one) and (two == 0):
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
c4 = sum(1 for x in a if x % 4 == 0)
c1 = sum(1 for x in a if x % 2 == 1)
if c4 >= c1 or (c4 >= c1 - 1 and c4 + c1 == n):
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
arr = list(map(int, input().split()))
four_count = 0
two_count = 0
for i in arr:
    if i % 4 == 0:
        four_count += 1
        continue
    if i % 2 == 0:
        two_count += 1
if 0 < four_count:
    N -= four_count * 2
if N <= 1:
    print('Yes')
    exit()
if N <= two_count:
    print('Yes')
    exit()
print('No')

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
c4 = 0
c2 = 0
for a in A:
    if a % 4 == 0: c4 += 1
    elif a % 2 == 0: c2 += 1

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

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

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

if n2 != 0:
    n -= (n2-1)
print('Yes' if n4 >= n//2 else 'No')

Solution (Python):

def examC():
    N = I()
    A = LI()
    multi2 = 0; multi4 = 0
    for i in A:
        if i%4==0:
            multi4 +=1
        elif i%2==0:
            multi2 +=1
    if multi4>=(N//2):
        ans = "Yes"
    elif (multi4*2 + multi2)>=N:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)



import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
n=int(input())
a = list(map(int, input().split()))
cnt4=0
cnt_odd=0
cnt_even=0
ans="Yes"
for i in a:
    if i%4==0:
        cnt4+=1
    elif i%2==0:
        cnt_even+=1


if cnt4 >= n // 2:
    print('Yes')
elif n - cnt4*2 <= cnt_even:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
lists=list(map(int,input().split()))
mod_4=[]
mod_2=[]
elser=[]
for i in lists:
    if i%4==0:
        mod_4.append(i)
    elif i%4==2:
        mod_2.append(i)
    else:
        elser.append(i)
number_of_4=len(mod_4)
if number_of_4>=(n//2):
    print("Yes")
else:
    j=number_of_4*2+len(mod_2)
    if j>=n:
        print("Yes")
    else:
        print("No")

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

cnt2 = cnt2 if cnt2%2==0 else cnt2-1
print('Yes' if (N-cnt2)//2<=cnt4 else 'No')

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


if zero-1<=two and one%2==0:
    print('Yes')
elif two*2>=N-1:
    print('Yes')
elif zero<=two:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
dic = {1:0,2:0,4:0}
for a in A:
    if a % 4 == 0: dic[4] += 1
    elif a % 2 == 0: dic[2] += 1

dic[1] = N - dic[2] - dic[4] + (dic[2] != 0)
if dic[1] <= dic[4]+1: print('Yes')
else: print('No')

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
from collections import defaultdict as dd
dic = dd(lambda: 0)
for num in A:
  if num % 4 == 0:
    dic[2] += 1
  elif num % 2 == 0:
    dic[1] += 1
  else:
    dic[0] += 1
if dic[2] >= dic[0]:
  print("Yes")
elif dic[0] - dic[2] == 1 and dic[1] == 0:
  print("Yes")
else:
  print("No")

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

four_count = 0
even_count = 0

for i in a:
    if i % 4 == 0:
        four_count += 1
    elif i % 2 == 0:
        even_count += 1

if four_count >= n // 2:
    print('Yes')
elif n - four_count*2 <= even_count:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
count2=0
count4=0
for i in range(n):
  if l[i]%4==0:
    count4+=1
  elif l[i]%2==0:
    count2+=1
if count4*2+count2>=n or count4*2+1>=n:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
t,f=0,0
for x in a:
  if x%4==0:
    f+=1
  elif x%2==0:
    t+=1
print('Yes' if max(0,t-1)+f*2+1>=n else 'No')

Solution (Python):

N = int(input())
a = list(map(int, input().split()))
cnt = 0
half = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] % 2 == 0:
        half += 1

if half % 2 != 0:
    half -= 1
if cnt >= (N - half)//2:
    print("Yes")
else:
    print("No")

Solution (Python):

N = int(input())
a = list(map(int, input().split()))
cnt = 0
half = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt += 1
    elif a[i] % 2 == 0:
        half += 1
cnt += half // 2
if cnt >= N//2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
alist = list(map(int, input().split()))
c2 = 0
c4 = 0
kisuu = 0
for a in alist:
    if a % 4 == 0:
        c4 += 1
    elif a % 2 == 0:
        c2 += 1
    else:
        kisuu += 1

if c4 >= (kisuu + (1 if c2 else 0)) - 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N= int(input())
A= [int(x) for x in input().split()]
c_2 = 0
c_4 = 0
for i in range(N):
  if A[i]%4==0:
    c_4 += 1
  elif A[i]%2==0 and A[i]%4!=0:
    c_2 += 1
c=N-c_4-c_2
print('Yes' if (c_2==0 and c_4>=c-1) or c_4>=c else'No')

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
two=0
four=0
out=0

for i in range(N):
    if a[i]%4==0:
        four=four+1
    elif a[i]%2==0:
        two=two+1
    else:
        out=out+1

if two%2!=0:
    out=out+1

if out<=four+1:
    print("Yes")
else:
    print("No")

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

cnt4 = 0
cnt1 = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt4+=1
    elif i % 2 != 0:
        cnt1+=1
    else:
        cnt2 += 1

if cnt4 >= cnt1:
    print("Yes")
elif cnt2 == 0 and cnt4 >= cnt1-1:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
odds=0
count_2=0
count_4=0
for u in a:
    if u%2==1:
        odds+=1
    elif u%4==0:
        count_4+=1
    else:
        count_2+=1
if count_2==0:
    if count_4>=odds-1:
        print("Yes")
    else:
        print("No")
else:
    if count_4>=odds:
        print("Yes")
    else:
        print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[1 for i in a if i%4==0]
c=[1 for i in a if i%4!=0 and i%2==0]
print("Yes" if len(b)+len(c)//2>=n//2 else "No")

Solution (Python):
N=int(input());v=[int(i)%4for i in input().split()];print('Yes'if v.count(0)+v.count(2)//2>=N//2 else'No')

Solution (Python):
N=int(input());A=input().split();v=[int(i)%4for i in A];print('Yes'if v.count(0)+v.count(2)//2>=N//2 else'No')

Solution (Python):
N=int(input());A=input().split();v=[int(i)%4 for i in A];print('Yes' if v.count(0)+v.count(2)//2>=N//2 else 'No')

Solution (Python):
from sys import stdin
n, *a = map(int, stdin.read().split())
c2, c4 = 0, 0
for i in a:
    if i % 2 == 0: 
        if i % 4 == 0:
            c4 += 1
        else:
            c2 += 1

if c4 >= len(a) // 2: ans = "Yes"
elif (len(a) - c4 * 2) == c2: ans = "Yes"
else: ans = "No"

print(ans)

Solution (Python):
from sys import stdin
n, *a = map(int, stdin.read().split())
c2, c4 = 0, 0
for i in a:
    if i % 2 == 0: c2 += 1
    if i % 4 == 0: c4 += 1

if c4 >= len(a) // 2: ans = "Yes"
elif (len(a) - c4 * 2) == (c2 - c4): ans = "Yes"
else: ans = "No"

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [0,0,0]
for i in range(n):
    j = 0
    while True:
        if a[i]%2==0:
            a[i] = a[i]//2
            j +=1
        else:
            b[j]+=1
            break

        if j>1:
            b[2]+=1
            break
if b[1]==0 and b[0]-1<=b[2]:
    print("Yes")
elif b[0]<=b[2]:
    print("Yes")
else:
    print("No")

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

    cnt_2 = 0
    cnt_4 = 0
    others = 0
    for ai in A:
        if ai % 4 == 0:
            cnt_4 += 1
        elif ai % 2 == 0:
            cnt_2 += 1
        else:
            others += 1

    

    ans = ''
    if cnt_4 > 0:
        if cnt_4 * 2 + 1 >= N:
            ans = 'Yes'
        elif cnt_4 * 2 + cnt_2 >= N:
            ans = 'Yes'
        else:
            ans = 'No'
    elif cnt_4 + cnt_2 >= N:
        ans = 'Yes'
    else:
        ans = "No"
        

    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):

import itertools

N = int(input())
a_list = [int(e) for e in input().split()]

def devide_2_and_4(n):
    if n%4==0:
        return(2)
    elif n%2==0:
        return(1)
    else:
        return(0)

a_list = [devide_2_and_4(a) for a in a_list]

cnt_four = a_list.count(2)
cnt_two = a_list.count(1)
cnt_one = a_list.count(0)






if cnt_four - cnt_one <= -2: 
    print("No")
elif cnt_two > 0 and cnt_four - cnt_one <= -1: 
    print("No")
else:
    print("Yes")

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in range(N):
  if a[i] % 4 == 0:
    c4 += 1
  elif a[i] % 2 == 0:
    c2 += 1
f = 1
t = N - 1
if c2 >= 2:
  t -= c2 - 1

if t // 2 + t % 2 > 0 and c4 == 0: f = 0
if c2 == N and c2 % 2 == 0:
  print("Yes")
  exit(0)
if t // 2 + t % 2 <= c4 and f:
  print("Yes")
else: print("No")

Solution (Python):
n=int(input())
da=list(map(int,input().split()))
co=[0,0,0]
for i in da:
    if i%4==0:
        co[0]+=1
    elif i%2==0:
        co[1]+=1
    else:
        co[2]+=1
if co[0] >= co[2]:
    print('Yes')
elif co[0]+1 == co[2] and co[1]==0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]

cnt_4 = 0
cnt_2 = 0
cnt_n = 0
for x in a:
    if x % 4 == 0:
        cnt_4 += 1
    elif x % 2 == 0:
        cnt_2 += 1
    else:
        cnt_n += 1

res = 'No'
if cnt_2:
    if cnt_4 >= cnt_n:
        res = 'Yes'
else:
    if cnt_4 >= cnt_n - 1:
        res = 'Yes'

print(res)

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

b = list(map(lambda x: x%4, a))

c1 = b.count(0)
c2 = b.count(2)

if c1 >= len(a)//2:
    print('Yes')
elif c2 >= len(a) - 2*c1:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
four,two,one = 0,0,0

for i in A:
    if i%4==0:
        four+=1
    elif i%2==0:
        two+=1
    else:
        one+=1

s=''
import sys
if one==0:
    print('Yes')
    sys.exit()
else:
    s+='1'
    one-=1

while four!=0 or two!=0 or one!=0:
    if s[-1]=='1':
        if four!=0:
            s+='4'
            four-=1
        else:
            print('No')
            sys.exit()
    elif s[-1]=='2':
        if two!=0:
            s+='2'
            two-=1
        elif four!=0:
            s+='4'
            four-=1
        else:
            print('No')
            sys.exit()
    else:
        if one!=0:
            s+='1'
            one-=1
        elif two!=0:
            s+='2'
            two-=1
        else:
            s+='4'
            four-=1

print('Yes')

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
B=[]
c1=0
c2=0
for a in A:
    if a%2==0:
        B.append(a//2)
        c1+=1
for b in B:
    if b%2==0:
        c1-=1
        c2+=1
if c1!=0 or c2!=0:
    if c1==0:
        if (n-1)-2*c2<=0:
            print('Yes')
            exit()
    else:
        if n-c1-2*c2<=0:
            print('Yes')
            exit()
print('No')

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    n = len(A)
    count4 = 0
    count2 = 0
    for a in A:
        if a % 4 == 0:
            count4 += 1
        elif a % 2 == 0:
            count2 += 1
    count2 = count2 // 2
    requirements = n // 2

    if requirements <= count4 + count2:
        return 'Yes'
    return 'No'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

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

k0=k1=k2=0
for ai in a:
    if ai%4==0:
        k2+=1
    elif ai%2==0:
        k1+=1
    else:
        k0+=1

if k1==0:
    f=k2*2+1>=N
else:
    f=k2*2+k1>=N

print('Yes' if f else 'No')

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

min_four = N//2
four_count = 0
for a in A:
  if a%4==0:
    four_count+=4
  elif a%2==0:
    four_count+=2

if min_four*4 <= four_count:
  print("Yes")
else:
  print("No")

Solution (Python):

def main():
    N, *A = map(int, open(0).read().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()))

count_4 = 0
count_2 = 0
count = 0
for i in range(n):
    if a[i] % 4 == 0:
        count_4 += 1
    elif a[i] % 2 == 0:
        count_2 += 1
    else:
        count += 1
if count_2 == 0:
    count_4 += 1
if count_4 >= count :
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = [int(_) for _ in input().split()]

cnt = 0
cnt2 = 0

for i in range(N):
    if a[i] % 2 == 0 and a[i] % 4 != 0:
        cnt2 += 1
    if a[i] % 4 == 0:
        cnt += 1

t = max(0, N -1- 2* cnt)
if t == 0: print('Yes') 
if t>0:
    if cnt2 >= t+1: print('Yes')
    else:
        print('No')

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

cnt1,cnt2,cnt3=0,0,0
for a in A:
  if a%4==0:
    cnt1+=1
  elif a%2==0:
    cnt2+=1
cnt1+=cnt2//2
print('Yes') if cnt1>=n//2 else print('No')

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
s=0
s1=0 
for i in l:
    if i%4==0:
        s+=1 
    elif i%2==0:
        s1+=1 
if s+s1//2>=n//2:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
s=0
o=0
for i in range(n):
    if a[i]%4==0:
        s+=1
    elif a[i]%2==1:
        o+=1

if n%2==0:
    if o-s<=0:
        print("Yes")
    else:
        print("No")
else:
    if o-s<=1:
        print("Yes")
    else:
        print("No")

Solution (Python):
N=int(input())
li=list(map(int,input().split()))
two_count=0
four_count=0
for n in range(N):
    if li[n]%4==0:
        four_count+=1
    elif li[n]%2==0:
        two_count+=1
S=max(four_count*2+1,four_count*2+two_count)
if S>=N:
    print('Yes')
else:
    print('No')

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

n2 = 0
n4 = 0
n0 = 0

for a in A:
    if a % 2 == 0 and a // 2 % 2 == 0:
        n4 += 1
    elif a % 2 == 0:
        n2 += 1
    else:
        n0 += 1

if n2 == 0:
    print("Yes" if n4 * 2 + 1 >= N else "No")
else:
    print("Yes" if n4 * 2 + n2 >= N else "No")

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

num_1=0
num_2=0
num_4=0

for i in range(N):
        if A[i] % 4 == 0:
                num_4+=1
        elif A[i] %2 == 0:
                num_2+=1
        else:
                num_1+=1

if num_2 == 0:
        if num_1 <= num_4+1:
                print("Yes")
        else:
                print("No")

else:
        if num_1 <= num_4:
                print("Yes")
        else:
                print("No")

Solution (Python):
n = int(input())
a = map(int, input().split())
cnt=0
twocnt=0
for i in a:
	if(i % 4 == 0):
		cnt+=1
	elif(i % 2 == 0):
		twocnt+=1
cnt += twocnt//2

if(cnt >= n//2):
	print ("Yes")
else:
	print ("No")

Solution (Python):
n = int(input())
list_a = list(map(int, input().split()))
multi_4 = 0
multi_2 = 0
multi_o = 0
for a in list_a:
  if a % 4 == 0:
    multi_4 += 1
  elif a % 2 == 0:
    multi_2 += 1
  else:
    multi_o += 1

if multi_2 > 1:
  if multi_4 >= (n - multi_2) / 2:
    print("Yes")
  else:
    print("No")
else:
  if multi_4 >= (n - 1) / 2:
    print("Yes")
  else:
    print("No")

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

cnt4,cnt2,cnt = 0,0,0

for i in A:
    if i%4==0:
        cnt4 += 1
    elif i%2==0:
        cnt2 += 1
    else:
        cnt += 1
cnt += cnt2%2

if cnt4+1>=cnt:
    print('Yes')
else:
    print('No')

Solution (Python):
def f(li):
    ret = [0] * 3
    for e in li:
        if e % 4 == 0:
            ret[2] += 1
        elif e % 2 == 0:
            ret[1] += 1
        else:
            ret[0] += 1

    return ret


def solve(li):
    cnt = f(li)
    q = [1] * cnt[0] + [2] * cnt[1] + [4] * cnt[2]

    fin = []
    for i in range(len(li)):
        if i % 2:
            fin.append(q.pop())
        else:
            fin.append(q.pop(0))

    bl = True
    for i in range(len(li) - 1):
        if fin[i] * fin[i+1] % 4 != 0:
            bl = False

    print("Yes" if bl else "No")


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

    solve(a)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
count4=0
countodd=0
for i in range(N):
  if a[i]%2==1:
    countodd+=1
  elif a[i]%4==0:
    count4+=1
if countodd + count4 == N:
  if countodd <= count4+1:
    print("Yes")
  else:
    print("No")
else:
  if countodd <= count4:
    print("Yes")
  else:
    print("No")

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

Solution (Python):
N = int(input())
A = list(map(lambda a: abs(int(a) % 4 - 2), input().split()))

odd = len(list(filter(lambda x: x == 1, A)))
even2 = len(list(filter(lambda x: x == 0, A)))
even4 = len(list(filter(lambda x: x == 2, A)))

even2 %= 2

if odd + (even2 % 2) <= even4 + 1:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
four = 0
two = 0
other = 0

for i in A:
    if i%4==0:
        four +=1
    elif i%2 ==0:
        two +=1
    else:
        other +=1

other += two%2
if four+1 >= other:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
G = {0:0,1:0,2:0}
for i in range(N):
    if A[i]%2==1:
        G[0] += 1
    else:
        a = A[i]//2
        if a%2==1:
            G[1] += 1
        else:
            G[2] += 1
if G[1]>0:
    if G[2]>=G[0]:
        print("Yes")
    else:
        print("No")
else:
    if G[2]>=G[0]-1:
        print("Yes")
    else:
        print("No")

Solution (Python):


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

a_4_multi, a_2_multi, a_odd = [], [], []

for x in a:
    if x%2 == 1:
        a_odd.append(x)
    elif x%4 != 0:
        a_2_multi.append(x)
    else:
        a_4_multi.append(x)
        
sort_a = []
for idx in range(N):
    if idx%2 == 0 and len(a_odd) >= 1:
        sort_a.append(a_odd.pop())
    elif idx%2 == 1 and len(a_4_multi) >= 1:
        sort_a.append(a_4_multi.pop())
    elif len(a_odd) == 0 and len(a_4_multi) >= 1:
        sort_a.append(a_4_multi.pop())
    elif len(a_odd) >= 1 and len(a_4_multi) == 0:
        sort_a.append(a_odd.pop())
    else:
        sort_a.extend(a_2_multi)
        break

for idx in range(N-1):
    if (sort_a[idx] * sort_a[idx+1])%4 != 0:
        print("No")
        exit()

print("Yes")

Solution (Python):
import bisect
def main():
    n=int(input())
    a=list(map(int,input().split((' '))))
    two=0
    four=0
    for i in a:
        if i%4==0:
            four += 1
        elif i%2==0:
            two += 1
    if n-(two//2)*2 <=2*four +1:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Solution (Python):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    as_ = list(map(int, input().split()))
    a_2_divisor_num = [0] * 3 
    for a in as_:
        if a % 4 == 0:
            a_2_divisor_num[2] += 1
        elif a % 2 == 0:
            a_2_divisor_num[1] += 1
        else:
            a_2_divisor_num[0] += 1
    
    if a_2_divisor_num[1] == 0:
        if a_2_divisor_num[0] <= a_2_divisor_num[2] + 1:
            print("Yes")
        else:
            print("No")
    else:
        if a_2_divisor_num[0] <= a_2_divisor_num[2]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

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

p,q,r = 0,0,0

for i in range(n):
    if A[i]%4 == 0:
        p += 1
    elif A[i]%2 == 0:
        q += 1
    else:
        r += 1

prev = 2
for i in range(n):
  if prev == 0:
    if p > 0:
      prev = 2
      p -= 1
    else:
      print('No')
      exit()
  elif prev == 1:
    if q > 0:
      prev = 1
      q -= 1
    elif p > 0:
      prev = 2
      p -= 1
    else:
      print('No')
      exit()
  else:
    if r > 0:
      prev = 0
      r -= 1
    elif q > 0:
      prev = 1
      q -= 1
    else:
      prev = 2
      p -= 1
print('Yes')

Solution (Python):


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

yon=0
ni=0
flag=False
ki=0

for a in A:
    if a%4==0:
        yon+=1
    elif a%2==0:
        ni+=1
        flag=True
    else:
        ki+=1

if flag:
    if (ki+1)-yon<=1:
        print("Yes")
    else:
        print("No")
else:
    if (ki-yon)<=1:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys
n=int(input())
a=list(map(int,input().split()))
cnt4=0
cnt2=0
for i in range(n):
  if a[i]%4==0:
    cnt4+=1
  elif a[i]%2==0:
    cnt2+=1
if n%2==1:
  if (2*cnt4)+1==n:
    print('Yes')
    sys.exit()
if n-(2*cnt4)<=cnt2:
    print('Yes')
    sys.exit()
else:
    print('No')
    sys.exit()

Solution (Python):
def solve():
    N = int(input())
    A = map(int, input().split())
    mod_2 = 0
    mod_4 = 0
    mod_odd = 0
    for a in A:
        if a % 4 == 0: mod_4 += 1
        elif a%2 == 0: mod_2 += 1
        else: mod_odd += 1
    
    mod_2 = mod_2 % 2
    print('Yes' if mod_4 - (mod_2 + mod_odd) >= -1 else 'No')
    
solve()

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a1 = 0
a2 = 0
a4 = 0
for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 +=1
    else:
        a1 += 1



if (a1 <= (a4+1) and a2 == 0) or a1 <= a4:
    print("Yes")
    
else:
    print("No")

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

four_count,two_count = 0,0
for i in range(N):
  if(A[i]%4 == 0): four_count += 1
  elif(A[i]%2 == 0): two_count += 1







if(two_count <= 1): Need = N
else: Need = N - two_count + 1
  
count = 0
if(four_count>=1): count += 2*four_count + 1
if(count >= Need): judge = 1
else: judge = 0

if(judge == 0): 
 if(N == two_count): judge = 1

if(judge == 0): print('No')
else: print('Yes')

Solution (Python):
n = int(input())
zero = 0
two = 0
four = 0
for i in map(int, input().split()):
  if i % 4 == 0:
    four += 1
  elif i % 2 == 0 and i % 4 != 0:
    two += 1
  else :
    zero += 1
flag = True
if zero > four:
  flag = False
  if zero == four + 1 and two == 0:
    flag = True

print('Yes' if flag else 'No')

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

m_4 = 0
even = 0

for i in range(N):
    if A[i] % 4 == 0:
        m_4 += 1
    elif A[i] % 2 != 0:
        even += 1

if (N % 2 == 0 and m_4 >= even) or (N % 2 != 0 and m_4 >= even - 1):
    print('Yes')
else:
    print('No')

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

cnt4 = 0
cnt1 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt4 += 1
    if a[i] % 2 != 0:
        cnt1 += 1

if cnt4 >= cnt1:
    print("Yes")
else:
    if N == cnt4 + cnt1 and cnt4 + 1 == cnt1:
        print("Yes")
    else:
        print("No")

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

B = [0, 0, 0]
for a in A:
  if a % 4 == 0:
    B[2] += 1
  elif a % 2 == 0:
    B[1] += 1
  else:
    B[0] += 1
print ("Yes" if B[0] <= B[2] or B[1] == 0 and B[0] - B[2] == 1 else "No")

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

B = [0, 0, 0]
for a in A:
  if a % 4 == 0:
    B[2] += 1
  elif a % 2 == 0:
    B[1] += 1
  else:
    B[0] += 1
print ("Yes" if B[0] <= B[2] or B[1] == 0 and B[0] - B[2] == 1 else "No")

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

cnt1,cnt2=0,0
for i in a:
    if i%2!=0:
        cnt1+=1
    if i%4==0:
        cnt2+=1
print('Yes' if cnt2>=cnt1 or (len(a)%2!=0 and cnt2+1>=cnt1) else 'No')

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

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

print("Yes" if four + 1 >= one + two % 2 else "No")

Solution (Python):
arraylen = int(input())
sequence = list(map(int, input().split()))
mulTwoCount = 0
mulFourCount = 0
otherCount = 0
for i in range(arraylen):
  if sequence[i] % 4 == 0:
    mulFourCount += 1
  elif sequence[i] % 2 == 0:
    mulTwoCount += 1
  else:
    otherCount += 1
if mulFourCount + 1 == otherCount and mulTwoCount == 0:
  ans = "Yes"
elif mulFourCount < otherCount:
  ans = "No"
else:
  ans = "Yes"
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
sum = 0
cnt_two = 0
for i in range(N):
  if A[i] % 4 == 0:
    sum += 1
  elif A[i] % 2 == 0:
    cnt_two += 1
print("Yes" if sum + cnt_two // 2 >= N // 2 else "No")

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

x4 = [x for x in a if x % 4 == 0]
x2 = [x for x in a if x % 4 != 0 and x % 2 == 0]

if len(x4) >= N // 2:
    ans = 'Yes'
else:
    if len(a) - len(x4) - len(x2) <= len(x4):
        ans = 'Yes'
    else:
        ans = 'No'
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
cnt3 = 0
for i in a:
    if i % 2 != 0:
        cnt3 += 1
    elif i % 4 == 0:
        cnt += 1
    else:
        cnt2 += 1

if cnt2 == 0:
    if cnt3 <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if cnt3 <= cnt:
        print('Yes')
    else:
        print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=0
y=0
for i in a:
    if i%4==2:
        y+=0.5
    elif i%4==0:
        x+=1

if x+int(y)>=(n-1)/2:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
odd = 0
even = 0
four = 0

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

if odd > four:
    if not (odd -1 == four and even == 0):
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a0 = 0
a2 = 0
a4 = 0

for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 += 1
    else:
        a0 += 1

if a4 >= a0:
    print('Yes')
elif a4 +1 == a0 and a2 ==0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a0 = 0
a2 = 0
a4 = 0

for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 += 1
    else:
        a0 += 1

if N == 3 and a4 >= 1:
    print('Yes')
elif a4 >= a0:
    print('Yes')
elif a4 +1 == a0 and a2 ==0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
odd = 0
even = 0
four = 0
for i in list(map(int,input().split())):
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        even += 1
    else:odd += 1
if four == 0:
    if even == n:
        print("Yes")
    else:print("No")
elif even+odd <= four+1:
    print("Yes")
elif four >= odd:
    print("Yes")
else:print("No")

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

for a in A:
    if a%4==0:
      x+=1
    elif a%2==0:
      y+=1

print(["No","Yes"][x+y//2>=N//2])

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

for a in A:
    if a%4==0:
      x+=1
    elif a%2==0:
      y+=1

print(["No","Yes"][x+y//2>=N//2])

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")