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



import sys
n = int(input())

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

cnt = 0

for l in a:
    if l % 2:
        pass
    elif l % 4:
        cnt += 1
    else:
        cnt += 2



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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

two = []
four = []
others = []

for v in a:
    if v % 4 == 0:
        four.append(v)
    elif v % 2 == 0:
        two.append(v)
    else:
        others.append(1)

if len(two) % 2 != 0:
    others.append(two[0])
if len(four) + 1 >= len(others):
    print('Yes')
else:
    print('No')

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

odd, four = 0, 0 
for x in a:
    if x % 2 == 1:
        odd += 1
    if x % 4 == 0:
        four += 1

two = n - odd - four
if two > 0:
    odd += 1
    
if four + 1 >= odd:
    print('Yes')
else:
    print('No')

Solution (Python):
N,*A=map(int,open(0).read().split())

x4 = 0
x2 = 0
x1 = 0

for i in range(N):
  if A[i]%4 == 0:
    x4+=1
  elif A[i]%2 == 0:
    x2+=1
  else:
    x1 +=1
if x1 +min(1,x2)<= x4+1:
  print("Yes")
else:
  print("No")

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

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

odd = n - div - even
if even:
    odd += 1
if div:
    div += 1

if div >= odd or even == n:
    print("Yes")
else:
    print("No")

Solution (Python):


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

b1, b4 = 0, 0
for a in A:
    if a % 2:
        b1 += 1
    if a % 4 == 0:
        b4 += 1

b2 = min(1, n-(b1+b4))

if b1+b2-1 <= b4:
    print("Yes")
else:
    print("No")

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

n0, n2, n4 = 0, 0, 0

for a in al:
    if a % 4 == 0:
        n4 += 1
    elif a % 2 == 0:
        n2 += 1
    else:
        n0 += 1

print('Yes' if n4+1 >= n0+n2%2 else 'No')

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

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

Solution (Python):
import sys
N = int(input())
A = list(map(int,input().split()))
k = 0
l = 0
m = 0
for i in range(N):
    if A[i] % 4 == 0:
        m += 1
    elif A[i] % 2 == 0:
        l += 1
    else:
        k += 1
if N <= 3:
    if m > 0:
        print('Yes')
        sys.exit()
    if k > 0:
        print('No')
        sys.exit()
    else:
        print('Yes')
        sys.exit()

if l == 0 and k == m + 1:
    print('Yes')
    sys.exit()


if k <= m:
    print('Yes')
else:
    print('No')

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

f, t = 0, 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
print('Yes' if f*2 + t >= n or n // 2 <= f else 'No')

Solution (Python):

n = int(input())
cnt2 = 0
cnt4 = 0
A = list(map(int, input().split()))
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1
odd = n - cnt2 - cnt4
if cnt2 != 0:
    odd += 1

if odd - 1 > cnt4:
    print("No")
else:
    print("Yes")

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

four = 0
two = 0
other = 0

for a in A:
    if a%4 == 0:
        four += 1
    elif a%2 == 0:
        two += 1
    else:
        other += 1
        
if two:
    if (other+1) <= four+1:
        print("Yes")
    else:
        print("No")
else:
    if other <= four+1:
        print("Yes")
    else:
        print('No')

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

cnt2 = 0
cnt4 = 0
cnt = 0

for i in a:
    if i%4==0:
        cnt4 += 1
    elif i%2==0:
        cnt2 += 1
    else:
        cnt += 1
ans = 0
if (cnt - cnt4 == 1 and cnt2 == 0) or (cnt4>=cnt):
    ans = 1
print("Yes" if ans==1 else "No")

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

i1=len([i for i in A if i%2!=0])
i4=len([i for i in A if i%4==0])
i2=min(1,N-i1-i4)


print('Yes' if (i1+i2-1)<=i4 else 'No')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
odd = 0
even = 0
even4 = 0
 
for num in A:
    if num % 2 == 1:
        odd += 1
    else:
        even += 1
    if num % 2 == 0 and num % 4 != 0:
        even4 += 1
even4 = even - even4
    
if odd == 0 or odd <= even4 or (odd + even4 == N and odd == even4 + 1):
    print("Yes")
else:
    print("No")

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

for num in A:
    if num % 2 == 1:
        odd += 1
    else:
        even += 1
    if num % 2 == 0 and num % 4 != 0:
        even4 += 1
even4 = even - even4
    
if odd == 0 or odd <= even4 or (odd + even4 == N and odd == even4 + 1):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
aa = list(map(int, input().split()))
c1 = 0 
c2 = 0 
c4 = 0
la = len(aa)

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
  else:
    c1 += 1
    
if c1 == 0:
  print('Yes')
  exit()

elif c4 >= c1:
  print('Yes')
  exit()
  
elif c4 == c1 - 1 and c2 == 0:
  print('Yes')
  exit()
  
print('No')

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

s = "No"
if N//2 <= q or N <= 2*q+b:
  s = "Yes"
print(s)

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

c_4=0
even=0
odd=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    even+=1
  else:
    odd+=1
  
if even==0 and odd-1 <= c_4:
  ans="Yes"
else:
  ans="No"
  
if even>0 and odd <= c_4:
  ans="Yes"
elif even>0:
  ans="No"

print(ans)

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

c_4=0
even=0
odd=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    even+=1
  else:
    odd+=1
  
if even==0 and odd-1 <= c_4:
  ans="Yes"
else:
  ans="No"
  
if even>0 and odd <= c_4:
  ans="Yes"
else:
  "No"

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
baisu = [0,0,0]
flag = 0

for i in a:
    if i % 4 == 0:
        baisu[2] += 1
    elif i % 2 == 0:
        baisu[1] += 1
    else:
        baisu[0] += 1

if baisu[0] == 0 and (baisu[2] != 0 or baisu[1] != 1):
    flag = 1

if baisu[1] == 0 and baisu[2]+1 == baisu[0]:
    flag = 1

while baisu[2] != 0:
    baisu[2] -= 1
    baisu[0] -= 1

if baisu[0] < 1 or flag == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,A = ilint()
c = [0]*3
for a in A:
    if a%4==0:
        c[2] += 1
    elif a%2==0:
        c[1] += 1
    else:
        c[0] += 1

judge(c[0]<=c[2] or (c[0]==c[2]+1 and c[1]==0))

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

cnt_4, cnt_2 = 0, 0
for num in a:
    if num % 4 == 0:
        cnt_4 += 1
    elif num % 2 == 0:
        cnt_2 += 1

if n//2 <= cnt_4 + cnt_2//2:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
odd=0
even=0
res=0
for i in range(n):
  if a[i]%4==1 or a[i]%4==3:
    odd+=1
  elif a[i]%2==0 and a[i]%4!=0:
    even+=1
  else:
    res+=1
if even<2:
  if odd+even-1<=res:
    print('Yes')
  else:
    print('No')
else:
  if odd<=res:
    print('Yes')
  else:
    print('No')

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
b2 = 0
b4 = 0

for i in range(N):
    if L[i] % 4 == 0:
        b4 += 1
    elif L[i] % 2 == 0:
        b2 += 1
other = N-b4-b2
if b2 != 0:
    other += 1
print('Yes' if other<= b4+1 else 'No')

Solution (Python):
N = int(input())

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

num_0, num_2, num_4 = 0, 0, 0

for i in a_li:
    if i % 4 == 0:
        num_4 += 1
    elif i % 2 == 0:
        num_2 += 1
    else:
        num_0 += 1

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

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

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
c=[0]*3
for a in A:
    if a%2!=0:
        c[0]+=1
    elif a%4==0:
        c[2]+=1
    else:
        c[1]+=1

if c[2]<c[0]-1:
    print("No")
else:
    c[2]-=(c[0]-1)
    if c[1]==0:
        print("Yes")
    else:
        if c[2]>0:
            print("Yes")
        else:
            print("No")

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

cnt = 0
cnt4 = 0
for i in a:
    if i%2==1:
        cnt+=1
    if i%4==0:
        cnt4+=1
    
if n-cnt == cnt4:
    if cnt4>=n//2:
        print('Yes')
    else:
        print('No')
elif cnt4>=cnt:
    print('Yes')
else:
    print('No')

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

Solution (Python):

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

multiple4 = 0
multiple2 = 0
for a in A:
    if a%4 == 0:
        multiple4 += 1
    elif a%2 == 0:
        multiple2 += 1

odd = N - (multiple4 + multiple2)
result = 'No'
if odd <= multiple4:
    result = 'Yes'
elif ((odd - 1) <= multiple4) and (multiple2%2 == 0):
    result = 'Yes'
print(result)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ju = 0
for i in range(n): 
  if(a[i]%4==0):
      ju +=1
  elif(a[i]%2!=0):
    ju -= 1
if(n%2==1):
  ju += 1
if(ju>=0):
  print("Yes")
else:
  print("No")

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

x = y = z = 0

for i in range(N):
    if a[i] % 4 == 0:
        x += 1
    elif a[i] % 2 == 0:
        y += 1
    else:
        z += 1

if x >= min(1, y) + z - 1:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def get_2(i):
    cnt = 0
    while i % 2 == 0 and i > 0:
        i = i // 2
        cnt += 1
    return cnt


def main():
    n = input_int()
    A = input_int_list()
    odd = 0
    even_4 = 0
    even_2 = 0
    for a in A:
        if a % 4 == 0:
            even_4 += 1
        elif a % 2 == 0:
            even_2 += 1
        else:
            odd += 1
    if even_4 >= odd:
        print("Yes")
    elif odd == 0 and even_2 > 1:
        print("Yes")
    elif odd == 0 and even_4 == 0 and even_2 == 1:
        print("No")
    elif even_4 == odd - 1 and even_2 == 0:
        print("Yes")
    elif even_4 == odd - 1 and even_2 > 0:
        print("No")
    elif even_4 < odd - 1:
        print("No")
    else:
        print("No")
    return


if __name__ == "__main__":
    main()

Solution (Python):

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

b0,b1,b2 = 0,0,0

for i in range(N):
    if a[i]%2==1:
        b0+=1
    elif a[i]%4==0:
        b2+=1
    else:
        b1+=1

if b1==0:
    if b2>=b0-1:
        print('Yes')
    else:
        print('No')

else:
    b0+=1
    if b2>=b0-1:
        print('Yes')
    else:
        print('No')

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

c4 = 0
c2 = 0
for i in a:
    if i % 4 == 0:
        c4 += 1
    elif i % 2 == 0:
        c2 += 1

if n - c4 - c2 <= c4:
    print('Yes')
elif n - c4 - c2 - 1 <= c4 and c2 == 0:
    print('Yes')
else:
    print('No')

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    a = LI()
    a4, a2, a1 = [0 for _ in range(3)]
    for i in a:
        if i%4 == 0:
            a4 += 1
        elif i%2 == 0:
            a2 += 1
        else:
            a1 += 1
    if a1 == 0:
        print("Yes")
    else:
        if a4 == 0:
            print("No")
        elif a2 == 0:
            print("Yes" if a4 >= a1 -1 else "No")
        else:
            print("Yes" if a4 >= a1 else "No")
main()

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

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

four = len([a for a in A if a%4 == 0])
two = len([a for a in A if a%2 == 0]) - four
one = N - four - two

ans = 'No'
if two:
    one += 1
N = one + four
if N//2 <= four:
    ans = 'Yes'

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
for a in A:
    if a % 4 == 0:
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
cnt = N - 2*cnt_4 - cnt_2
if cnt_4 > 0 and N % 2 == 1:
    cnt -= 1
if cnt <= 0:
    print("Yes")
else:
    print("No")

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

odd=0
ev=0
evev=0
for i in range(N):
  if A[i]%2==0:
    if A[i]%4==0:
      evev+=1
    else:
      ev+=1
  else:
    odd+=1
if evev+1>odd or (evev+1==odd and ev==0):
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a0 = sum(i % 2 != 0 for i in a)
if sum(i % 4 == 2 for i in a) > 0:
    a0 += 1
a2 = sum(i % 4 == 0 for i in a)
print('Yes' if a0 <= a2 + 1 else 'No')

Solution (Python):
import math
n=int(input())
A=list(map(int,input().split()))
t4=0
t2=0
t=0
for i in A:
  a = math.log2(i & -i)
  if a>=2:
    t4+=1
  elif a==1:
    t2+=1
  else:
    t+=1
if t4 >= t+(t2 % 2) -1:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x1 = []
x2 = []
x4 = []
for i in range(n):
    if a[i] % 4 == 0:
        x4.append(a[i])
    elif a[i] % 2 == 0:
        x2.append(a[i])
    else:
        x1.append(a[i])
if len(x2) == 0:
    if len(x1) <= len(x4)+1:
        print("Yes")
    else:
        print("No")
else:
    if len(x1) <= len(x4):
        print("Yes")
    else:
        print("No")

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

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
a = []
c = [0,0,0]
for a_i in A:
    cnt = 0
    while a_i % 2 == 0:
        a_i //= 2
        cnt = min(2,cnt+1)
    c[cnt] += 1
    a.append(cnt)

if (c[2] + c[1] // 2) >= (n // 2):
    print("Yes")
else:
    print("No")

Solution (Python):



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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Solution (Python):



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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


if N%2==1:  
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:   
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Solution (Python):



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

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


if N%2==1:  
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:   
    if other%2==1:  
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
    else:
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()

Solution (Python):
n = int(input())
an = list(map(int, input().split()))
classify = [0 for i in range(3)]

for i in range(len(an)):
    if an[i] % 4 == 0:
        classify[0] += 1
    elif an[i] % 2 == 0:
        classify[1] += 1
    else:
        classify[2] += 1
if classify[1]==0:
    if(classify[0]+1) < classify[2]:
        print("No")
    else:
        print("Yes")

elif (classify[0]) < classify[2]:
    print("No")
else:
    print("Yes")

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


num_2n = sum([(a%2==0) for a in A_list])
num_4n = sum([(a%4==0) for a in A_list])
num_2n1 = sum([(a%2==1) for a in A_list])

if num_2n == N:
    print('Yes')
else:
    
    if num_4n + num_2n1 == N:
        if num_4n >= N//2:
            print('Yes')
        else:
            print('No')
    
    else:
        if num_4n >= num_2n1:
            print('Yes')
        else:
            print('No')

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

a_mod = list(map(lambda x:x%4, a))
c = collections.Counter(a_mod)

if c[2] == 0 and c[0] +1 == c[1] + c[3]:
  print("Yes")
elif c[0] >= c[1] + c[3]:
  print("Yes")
else:
  print("No")

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

if x == 0:
  ans = 'Yes'
elif y == 0:
  if x <= z + 1:
    ans = 'Yes'
  else:
    ans = 'No'
else:
  if x > z:
    ans = 'No'
  else:
    ans = 'Yes'
print(ans)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
m2 = 0
m4 = 0
for a in A:
    m2 += int(a%2 == 0 and not a%4 == 0)
    m4 += int(a%4 == 0)
if m4 >= N//2:
    print("Yes")
elif m4*2 + m2 >= N:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
numbers = list(map(int, input().split()))
odd_num_cnt = 0
even_num_cnt = 0
four_mal_cnt = 0
for i in numbers:
    if i % 4 == 0:
        four_mal_cnt += 1
    elif i % 2 == 0:
        even_num_cnt += 1
    else:
        odd_num_cnt += 1
if four_mal_cnt >= odd_num_cnt or (four_mal_cnt == odd_num_cnt - 1 and even_num_cnt == 0):
    print("Yes")
else:
    print("No")

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

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

n1 = 0
n2 = 0
n4 = 0

for ai in a:
    if ai % 2 == 0:
        if ai % 4 == 0:
            n4 += 1
        else:
            n2 += 1
    else:
        n1 += 1

if n1 > n4:
    if (n4 >= 1) and (n1 == (n4 + 1)) and n2 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):


n = int(input())

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

def PrimeFactorization(n):
    ret = []
    for i in range(2, int((n**0.5)+1)):
        if n % 2 != 0:
            continue

        exp = 0
        while(n % i == 0):
            exp += 1
            n //= i
        ret.append([i, exp])
    if n!= 1:
        ret.append([n, 1])
    
    return ret

odd = 0
even1 = 0
even2 = 0

for i in range(n):
    if data[i] % 2 != 0:
        odd += 1
    else:
        exp = 0
        tmp = data[i]
        while(tmp % 2 == 0):
            exp += 1
            tmp //= 2
        if exp == 1:
            even1 += 1
        elif exp >= 2:
            even2 += 1

if even1 == 0:
    if odd > even2+1:
        print("No")
    else:
        print("Yes")
else:
    if odd > even2:
        print("No")
    else:
        print("Yes")

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


if cnt[2] < cnt[0]-1:
    print('No')
else:
    if cnt[2] == cnt[0]-1:
        if cnt[1]:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

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

num_4 = 0
num_2 = 0
num_1 = 0
for ai in a:
    if(ai%4==0):
        num_4 += 1
    elif(ai%2==0):
        num_2 += 1
    else:
        num_1 += 1

if(num_4 >= num_1):
    print('Yes')
elif(num_4 + 1 == num_1)&(num_2==0):
    print('Yes')
else:
    print('No')

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

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

wari = [0]*3

for a in A:
    if a % 4 == 0:
        wari[2] += 1
    elif a % 2 == 0:
        wari[1] += 1
    elif a % 2 == 1:
        wari[0] += 1

if wari[1] == 0:
    if wari[2] + 1 >= wari[0]:
        print("Yes")
    else:
        print("No")

else:
    if wari[2] >= wari[0]:
        print("Yes")
    else:
        print("No")

Solution (Python):


from collections import Counter

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

d = Counter(a)

a_odd  = sum(v for k,v in d.items() if k % 2 == 1)
a_quad = sum(v for k,v in d.items() if k % 4 == 0)


if a_odd + a_quad == N and a_quad == a_odd - 1:
  print("Yes")
elif a_quad >= a_odd:
  print("Yes")
else:
  print("No")

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

T=[0,0,0]
for a in A:
    if a%2:
        T[0]+=1
    elif a%4:
        T[1]+=1
    else:
        T[2]+=1

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

Solution (Python):
ans='No'
n=int(input())
a=list(map(int, input().split()))
f=0
t=0
for i in a:
  if i%4==0:
    f+=1
  elif i%2==0:
    t+=1
if n//2<=f or n-2*f<=t:
  ans='Yes'
print(ans)

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

o = 0
s = 0
f = 0
for a in A:

    if a % 2 == 0:
        if a % 4 == 0:
            f += 1
        else:
            s += 1
    else:
        o += 1
if s == 0:
    if f >= o-1:
        print("Yes")
    else:
        print("No")
else:
    if f >= o:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    cnt = [0,0,0,0]
    for i in a:
        if i % 4 == 0:cnt[2] += 1
        elif i % 2 == 0:cnt[1] += 1
        elif i == 1:cnt[0] += 1
        else:cnt[3] += 1
    
    if cnt[2] >= cnt[0] + cnt[1] + cnt[3] - 1:print("Yes")
    elif cnt[2] >= cnt[0] + cnt[3]  and cnt[1] >= 2:print("Yes")
    else:print("No")

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

if c[1] == 0:
    if c[0] <= c[2]+1:
        print('Yes')
    else:
        print('No')
else:
    if c[0] <= c[2]:
        print('Yes')
    else:
        print('No')

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

four = 0
odd = 0

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

if odd == 0:
    print('Yes')
else:
    if four + odd == n:
        print('Yes' if four >= n // 2 else 'No')
    else:
        print('Yes' if four >= (four + odd + 1) // 2 else 'No')

Solution (Python):

n, *a = map(int, open(0).read().split())
o = sum(i % 2 > 0 for i in a)
q = sum(i % 4 < 1 for i in a)
if n == o + q and o - 1 == q:
    print("Yes")
else:
    print("YNeos"[o > q::2])

Solution (Python):

n = int(input())

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

can4 = 0
even = 0
odd = 0

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

if even == 0 and odd == can4 + 1:
    print("Yes")
elif odd > can4:
    print("No")
else:
    print("Yes")

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

cnt_1 = 0
cnt_2 = 0
cnt_4 = 0

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

if cnt_4 >= cnt_1:
    print('Yes')
else:
    if cnt_2 == 0 and cnt_1 - cnt_4 == 1:
        print('Yes')
    else:
        print('No')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
four_num = 0
odd_num = 0
for a in A:
    if a % 4 == 0:
        four_num += 1
    elif a % 2 == 1:
        odd_num += 1
t = 0
if four_num + odd_num == N:
    t = 1
if four_num >= odd_num - t:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
A = []
B = []
C = []
for i in range(N):
  if a[i]%4 == 0:
    A.append(a[i])
  elif a[i]%2 == 0:
    B.append(a[i])
  else:
    C.append(a[i])
if len(B) == 0 and len(A)+1 >= len(C):
  print('Yes')
elif len(A) >= len(C):
  print('Yes')
else:
  print('No')

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

m4 = sum([1 for i in range(n) if a[i]%4==0])
m2 = sum([1 for i in range(n) if a[i]%2==0])
m2 -= m4
m1 = n-m4-m2

n-=m2-1
if m2>0:
    m1+=1


if m4>=m1-1:
    print('Yes')
else:
    print('No')

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

if N%2==1:
    if a>b+1:
        print('No')
    else:
        print('Yes')
else:
    if a<=b:
        print('Yes')
    else:
        print('No')

Solution (Python):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 

 










 
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 one == 0:
    print('Yes')
elif two > 0:
    if four >= one:
        print('Yes')
    else:
        print('No')
else:
    if four >= one - 1:
        print('Yes')
    else:
        print('No')

Solution (Python):
N=int(input())
a=map(int,input().split())
c=0
d=0
e=0
f=0
for i in a:
  if i%4==0:
    c=c+1
  elif i%2==0:
    d=d+1
  e=N-c-d
if d==0:
  if (c+1)>=e:
    print('Yes')
  else:
    print('No')
    
else:
  if c>=e:
    print('Yes')
  else:
    print('No')

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

cnt2 = sum(i % 4 == 2 for i in a)
cnt4 = sum(i % 4 == 0 for i in a)
print('Yes 'if n <= 2 * cnt4 + max(1, cnt2) else 'No')

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

cnt1 = sum(i % 4 == 2 for i in a)
cnt2 = sum(i % 4 == 0 for i in a)
print('Yes 'if n <= 2 * cnt2 + max(1, cnt1) else 'No')

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

cnt1 = sum(i % 4 == 2 for i in a)
cnt2 = sum(i % 4 == 0 for i in a)
if n - 2 * cnt2 - max(1, cnt1) <= 0:
    print('Yes')
else:
    print('No')

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

res = [0]*3

for x in a:
    if x%4==0: res[2] += 1
    elif x%2==0: res[1] += 1
    else: res[0] += 1



ans = ""
if res[0]==0:
    ans = "Yes"
else:
    if res[1]==0:
        if res[2]+1 >= res[0]:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if res[2] >= res[0]:
            ans = "Yes"
        else:
            ans = "No"
        

print(ans)