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

L1 = 0
L4 = 0
for a in A:
    if a % 4 == 0:
        L4 += 1
    elif a % 2 == 1:
        L1 += 1

ans = 'No'
if L1 + L4 == N:
    if L4 + 1 >= L1:
        ans = 'Yes'
else:
    if L4 >= L1:
        ans = 'Yes'
print(ans)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    cnt4 = 0
    cnt2 = 0
    cnt = 0
    for i in a:
        if i%4 == 0:
            cnt4 += 1
        elif i%2 == 0:
            cnt2 += 1
        else:
            cnt += 1
    
    if cnt2 == 0:
        if cnt<= cnt4+1:
            print('Yes')
            return
        else:
            print('No')
            return
            
    total = 2* cnt4 + cnt2
    if total>= n:
        print('Yes')
    else:
        print('No')

solve()

Solution (Python):
N=int(input())
*A,=map(lambda x:int(x)%4,input().split())
f=A.count(0)
t=A.count(2)
o=N-f-t
if t==0:print("Yes"if f>o-2 else"No")
else:print("Yes"if f>=o else"No")

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
x,y=0,0
for a in A:
  if a%4==0:
    x+=1
  elif a%2==0:
    y+=1
if (n-y)%2==0 or y==0:
  d=(n-y)//2
else:
  d=(n-y)//2+1
print("Yes" if x>=d else "No")

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    cnt_4time = 0
    cnt_2time = 0
    for i in range(N):
        if a[i] % 4 == 0:
            cnt_4time +=1
        elif a[i] % 2 ==0:
            cnt_2time +=1
    N = N - (cnt_2time//2)*2
    if N <= 2*(cnt_4time)+1:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

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

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = []
    for a in A:
        if a % 4 == 0:
            B.append(2)
        elif a % 2 == 0:
            B.append(1)
        else:
            B.append(0)
    four_num = B.count(2)
    two_num = B.count(1)
    one_num = B.count(0)

    if two_num == 0:
        if four_num >= one_num - 1:
            print("Yes")
        else:
            print("No")
    else:
        if four_num >= one_num:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split(" ")))
count = [0, 0, 2]
for num in a:
    if num % 2 == 0:
        if num % 4 == 0:
            count[2] += 1
        else:
            count[1] += 1
    else:
        count[0] += 1

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
maru = len([a for a in A if a % 4 == 0])
batu = len([a for a in A if a % 2 == 1])
sankaku = N - maru - batu

if sankaku:
    if batu <= maru:
        print('Yes')
    else:
        print('No')
else:
    if batu <= maru + 1:
        print('Yes')
    else:
        print('No')

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

num2 = 0
num4 = 0

for i in a:
    if i % 2 == 0:
        if i%4 == 0:
            num4 += 1
        else:
            num2 += 1

judge = num4 * 2 + 1 * int(num2 < 2) + num2 * int(num2 > 1)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans='No'
a2=[i//2 for i in a if i%2==0]
a4=[i for i in a2 if i%2==0]
la2=len(a2)
la4=len(a4)
if la2+la4>=n and la2>0:
    ans='Yes'
elif la2==la4 and 2*la4+1>=n:
    ans='Yes'
print(ans)

Solution (Python):
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = nl()
p1 = 0
p2 = 0
p3 = 0
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 4 == 0:
            p3 += 1
        else:
            p2 += 1
    else:
        p1 += 1
if p1 <= p3:
    print('Yes')
else:
    if p1 == p3 + 1 and p2 == 0:
        print('Yes')
    else:
        print('No')

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

cnt1 = 0
cnt2 = 0
cnt4 = 0

for d in map(int,input().split()):
    if d%4==0:
        cnt4+=1
        continue
    if d%2==0:
        cnt2+=1
        continue
    cnt1+=1
res = True
if cnt2>0:
    res = (cnt1<=cnt4)
else:
    res = (cnt1<=(cnt4+1))

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

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


m=n//2
cnt=0
for i in range(n):
  if a[i]%2==0:
    cnt+=1
    if a[i]%4==0:
      cnt+=1

print('Yes' if cnt>=2*m else 'No')

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

t4=0
t2=0
t=0
for a in A:
  if a%4==0:
    t4+=1
  elif a%2==0:
    t2+=1
  else:
    t+=1
if t4>=t or (t2==0 and t4+1==t):
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
from math import ceil
n=int(input())
ans4=0
ans2=0
ans0=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    ans0+=1
if ans2>0:
  if ans0<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil((ans0+ans4)/2)>=ans0:
    print('Yes')
  else:
    print('No')

Solution (Python):
from collections import Counter
n=int(input())
counter=Counter(1 if x % 2 else 2 if x % 4 else 4 for x in (int(s) for s in input().split()))
print('Yes' if counter[1] <= counter[4] or counter[2] == 0 and counter[1] == counter[4] + 1 else 'No')

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
nu1 = 0
nu2 = 0
nu4 = 0
for nu in lis:
    if nu % 2 == 0:
        if nu % 4 == 0:
            nu4 += 1
        else:
            nu2 = 1
    else:
        nu1 += 1
if nu4 + 1 >= nu1 + nu2:print("Yes")
else:print("No")

Solution (Python):
from math import ceil
N = int(input())
A = list(map(int, input().split()))
num2 = 0
num4 = 0
numO = 0
for num in A:
    if num % 4 == 0:
        num4 += 1
        continue
    elif num % 2 == 0:
        num2 += 1
        continue
    else:
        numO += 1
if num2 > 0:
    if numO > num4:
        print('No')
    else:
        print('Yes')
else:
    if numO > ceil((num4 + numO) / 2):
        print('No')
    else:
        print('Yes')

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

x=0
y=0
for a in A:
    if a%2==0:
        if a%4==0:
            x+=1
        else:
            y+=1
if x+y//2>=n//2:
    print('Yes')
else:
    print('No')

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

tn = len(list (filter (lambda x: x%2==0 and x%4!=0,L )))
tf = len(list(filter(lambda x: x%4==0,L)))

if tn==0 and (N-tn)//2 <= tf:
  print('Yes')
elif tn!=0 and 2*tf >= N-tn:
  print('Yes')
else: 
  print('No')

Solution (Python):
N = input()
a = map(int, raw_input().split())
div4 = sum(map(lambda x: 1 if x % 4 == 0 else 0, a))
div2 = sum(map(lambda x: 1 if x % 2 == 0 else 0, a)) - div4
edge = 1 if div4 > 0 else 0
penalty = 1 if div2 == 1 else 0
if N <= div4 * 2 + edge or N <= div4 * 2 + div2 - penalty:
  print "Yes"
else:
  print "No"

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
f = 0
k = 0
for r in ar:
    if r % 4 == 0:
        f += 1
    if r % 2 == 1:
        k += 1
if k + f == a:
    if k <= f + 1:
        print("Yes")
    else:
        print("No")
else:
    if k <= f:
        print("Yes")
    else:
        print("No")

Solution (Python):
N=int(input())
n1,n2,n4=0,0,0
for i in input().split():
  if int(i)%4==0:
    n4+=1
  elif int(i)%2==0:
    n2+=1
  else:
    n1+=1
if n2==0:
  if n4>=n1-1:
    print("Yes")
  else:
    print("No")
else:
  if n4>=n1:
    print("Yes")
  else:
    print("No")

Solution (Python):

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

four_num = 0
two_num = 0
odd_num = 0
for _ in a:
    if _%4==0:
        four_num+=1
    elif _%2==0:
        two_num+=1
    else:
        odd_num+=1

if odd_num>four_num and two_num>0:
    print("No")
elif odd_num>four_num+1 and two_num==0:
    print("No")
else:
    print("Yes")

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
k=len([i for i in a if i%2==1])
y=len([i for i in a if i%4==0])
g=n-k-y
if g:
    if k<=y:print('Yes')
    else:print('No')
else:
    if k<=y+1: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
    else:
        odd += 1
if even == 0:
    if four >= odd - 1:
        print('Yes')
    else:
        print('No')
else:
    if four >= odd:
        print('Yes')
    else:
        print('No')

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

p = 0
q = 0
r = 0

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

if q == 0 :
    if p >= r-1 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if p >= r :
        ans = "Yes"
    else :
        ans = "No"
        
print(ans)

Solution (Python):
def inpl(): return [int(i) for i in input().split()]

N = int(input())
a = inpl()
A4 = A2 = A1 = 0
for i in range(N):
    if a[i] % 4 == 0:
        A4 += 1
    elif a[i] % 2 == 0:
        A2 = 1
    else:
        A1 += 1

if (A4+A2+A1)//2 <= A4:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

N = int(input())
A = [int(x) for x in input().split()]

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

type = 4

for i in range(N):
    if type == 4:
        if n1 > 0:
            n1 -= 1
            type = 1
        elif n2 > 0:
            n2 -= 1
            type = 2
        elif n4 > 0:
            n4 -= 1
            type = 4
    elif type == 2:
        if n2 > 0:
            n2 -= 1
            type = 2
        elif n4 > 0:
            n4 -= 1
            type = 4
        else:
            print("No")
            sys.exit(0)
    else:
        if n4 > 0:
            n4 -= 1
            type = 4
        else:
            print("No")
            sys.exit(0)

print("Yes")

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

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

n2 = ax.count(2)
n1 = ax.count(1)
n0 = ax.count(0)
if n2 - n0 >= 0:
	print("Yes")
elif n2 - n0 == - 1:
	if n1 == 0:
		print("Yes")
	else:
		print("No")
else:
	print("No")

Solution (Python):
n=input()
cnt=[0]*4
for a in map(int, raw_input().split()):
	cnt[a%4]+=1
cnt[1]+=cnt[3]
print "Yes" if cnt[1]+int(cnt[2]!=0)<=cnt[0]+1 else "No"

Solution (Python):
n=input()
cnt=[0]*4
for a in map(int, raw_input().split()):
	cnt[a%4]+=1
cnt[1]+=cnt[3]
print "Yes" if cnt[1]+int(cnt[2]!=0)<=cnt[0]+1 else "No"

Solution (Python):

from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(input())
a, b, c = 0, 0, 0
for x in inpl():
    if x%4 == 0:
        a += 1
    elif x%2 == 0:
        b += 1
    else:
        c += 1

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

Solution (Python):
N = int(input())
cnt_f = 0
cnt_t = 0
for a in map(int, input().split()):
    if a % 4 == 0:
        cnt_f += 1
    elif a % 2 == 0:
        cnt_t += 1
if N // 2 <= cnt_f or N <= cnt_f * 2 + cnt_t:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict
import sys
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    if a%4==0:
        dd[4]+=1
    elif a%2==0:
        dd[2]+=1
    else:
        dd[1]+=1
a=dd[1]
b=dd[2]
c=dd[4]
if a>c:
    if N%2==1 and a==c+1 and b==0:
        print('Yes')
        sys.exit()
    print('No')
    sys.exit()
print('Yes')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
arr = [0] * 3

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

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

print()

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

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

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

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

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

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

if cnt2 > 0:
    if cnt4 >= cnt1:
        print "Yes"
    else:
        print "No"
else:
    if cnt4 + 1 >= cnt1:
        print "Yes"
    else:
        print "No"

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

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

c1 = sum(a % 2 == 1 for a in A)
c2 = sum(a % 4 == 2 for a in A)
c4 = sum(a % 4 == 0 for a in A)

if c1 > c4 + 1 or (c1 == c4 + 1 and c2 > 0):
  print("No")
else:
  print("Yes")

Solution (Python):
n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
a=0
aa=0
for i in l:
    if i%4==0:
        aa+=1
    elif i%2==0:
        a+=1
aaa=n-a-aa
aaa+=a%2
if aaa-1<=aa:
    print("Yes")
else:
    print("No")

Solution (Python):


import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


N = int(input())
d4 = 0
d2 = 0
for n in map(int, input().split(" ")):
    if n % 4 == 0:
        d4 += 1
    elif n % 2 == 0:
        d2 += 1
d1 = N - d4 - d2

if d2:
    print(["No", "Yes"][d4 >= d1])
else:
    print(["No", "Yes"][d4 >= d1 - 1])

Solution (Python):

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

j = 0
k = 0
for i in range(n):
    if a[i] %2 == 0:
        if a[i] % 4== 0:
            k += 1
        else:
            j += 1
l = n-j-k

if l <= k:
    print('Yes')
else:
    if j == 0 and l == k + 1:
        print('Yes')
    else:
        
        print('No')

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

Solution (Python):
def getdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = True

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = Fa;se
    finally:

        return array_result

arr_data = getdata()

n = int(arr_data[0][0])

arr = [int(arr_data[1][x]) for x in range(n)]
arr01 = [v for v in arr if v % 4 == 0]
arr02 = [v for v in arr if v % 4 != 0 and v % 2 == 0]

print("Yes" if len(arr) // 2 <= len(arr01) + len(arr02) //2 else "No")

Solution (Python):
n = int(input())
arr = map(int,raw_input().split())

n4 = 0
n1 = 0
for i in arr:
	if i%4 == 0 :
		n4 += 1
	elif i%2 == 1:
		n1 += 1

if len(arr) - n4 - n1 > 0 :
	if n4 >= n1 :
		print "Yes"
	else :
		print "No"

else :
	if n4 >= n1 - 1:
		print "Yes"
	else :
		print "No"

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

nums = [int(i) for i in input().split()]
baisuu = [0,0,0]
for n in nums:
  if n%4 == 0:
    baisuu[0] += 1
  elif n%2 == 0:
    baisuu[1] += 1
  else:
    baisuu[2] += 1
   
if baisuu[1] % 2 == 1:
  baisuu[2] += 1
if baisuu[0] >= baisuu[2]-1:
  print("Yes")
else:
  print("No")

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

Solution (Python):
'''input
3
1 10 100
'''
n = input()
arr = map(int,raw_input().split())
ev,od,mf = 0,0,0
for i in range(n):
	if arr[i]%4 == 0:
		mf += 1
		continue
	elif arr[i]&1:
		od += 1
	else:
		ev += 1
if mf >= od:
	print "Yes"
elif mf >= od-1 and ev == 0:
	print "Yes"
else:
	print "No"

Solution (Python):
def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


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


N = read()
A = readlist()

fac = [factor(A[i]) for i in range(N)]

num2 = fac.count(2)
num1 = fac.count(1)
num0 = fac.count(0)

if num2 >= num0 or (num2 == num0 - 1 and num1 == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
two = []
four = []

for i in a:
	if i % 4 == 0:
		four.append(i)
	elif i % 2 == 0:
		two.append(i)

if (2 * len(four) + len(two) >= n) or 2 * len(four) + 1 >= n:
	print("Yes")
else:
	print("No")

Solution (Python):
input();*a,=map(int,input().split());b=c=0
for x in a:
    if x%4==0:b+=1
    elif -~x%2:c+=1
print(['No','Yes'][len(a)-b-c-2+(c>0)<b])

Solution (Python):


import sys, math, copy




HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    assert len(ai) == n
    ones = 0
    twos = 0
    fours = 0
    for a in ai:
        if a % 4 == 0:
            fours += 1
        elif a % 2 == 0:
            twos += 1
        else:
            ones += 1
    if twos > 0:
        twos = 1
    if fours == 0 and (ones > 0):
        return False
    if fours + 1 < ones + twos:
        return False
    return True

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

Solution (Python):
n = int(input())
cou1 = 0
cou2 = 0
cou4 = 0
lis = list(map(int,input().split()))
for i in range(n):
    if lis[i] % 2 == 0:
        if lis[i] % 4 == 0:
            cou4 += 1
        else:
            cou2 += 1
    else:
        cou1 += 1
if cou2 == 0:
    if cou1 <= cou4 + 1:
        print("Yes")
    else:
        print("No")
else:
    if cou1 <= cou4:
        print("Yes")
    else:
        print("No")

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

if n%2 == 0:
    th = int(n/2)
else:
    th = int((n-1)/2)

count = 0
num_2 = 0
for a in a_list:
    if a%4 == 0:
        count += 1
    elif a%2 == 0:
        num_2 += 1

if n%2 == 0:
    if count >= th-int(num_2/2):
        print("Yes")
    else:
        print("No")
else:
    if count >= th-int(max((num_2-1), 0)/2):
        print("Yes")
    else:
        print("No")

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 0
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

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

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

if cnt2==0:
    if odd<=cnt4+1:print("Yes")
    else:print("No")
else:
    if odd<=cnt4:print("Yes")
    else:print("No")

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

b1 = 0
b2 = 0
b4 = 0
for ai in a:
	if ai % 2 == 0:
		if ai % 4 == 0:
			b4 += 1
		else:
			b2 += 1
	else:
		b1 += 1

ok = False
if b2 == 0:
	if  b1 <= b4 + 1:
		ok = True
else:
	if b1 <= b4:
		ok = True

print("Yes" if ok == True else "No")

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

multiple4 = 0
multiple2 = 0
odds = 0

for ai in a:
    if ai % 4 == 0:
        multiple4 += 1
    elif ai % 2 == 0:
        multiple2 += 1
    else:
        odds += 1

if multiple4 == 0:
    if odds == 0:
        print('Yes')
    else:
        print('No')
elif multiple4 >= odds or multiple4 + 1 == odds and multiple2 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):

from collections import Counter
import math
N = int(input())

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

li2 = []
li4 = []
liother = []

for a in As:
    if a%4 == 0:
        li4.append(a)
    elif a%2 == 0:
        li2.append(a)
    else:
        liother.append(a)

if len(li4) >= len(liother):
    print('Yes')
elif len(li4) == len(liother)-1 and len(li2) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
_ = raw_input()
four = two = one = 0
for i in raw_input().split(' '):
    if int(i)%4 == 0:
        four+=1
    elif int(i)%2 ==0:
        two+=1
    else:
        one+=1
if one>four+1 or (one==four+1 and two!=0):
    print('No')
else:
    print('Yes')

Solution (Python):
import  math

num = int(input())
val = [int(x) for x in input().split()]

two = 0
four = 0
for i in val:
    if i % 4 != 0 and i % 2 == 0:
        two += 1
    elif i % 2 == 0:
        four += 1

print("Yes" if math.floor((len(val) - abs(two-1 if two > 0 else 0))/2) <= four else "No")

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

Solution (Python):
N=int(input())
a=[int(i) for i in input().split()]
num4=0
num2=0
num1=0
for i in a:
        if i%4==0:
                num4+=1
        elif i%2==0:
                num2+=1
num1=N-num4-num2

if num2>0:
        num1+=1

if num1<=num4+1:
        print("Yes")
else:
        print("No")

Solution (Python):


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

b = [ a[i]%4 for i in range(n) ]
import collections
c = collections.Counter(b)

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

Solution (Python):
import sys
n = int(sys.stdin.readline().strip())
ar = [int(x) for x in sys.stdin.readline().split()]
f4, odd, even = 0, 0, 0
for num in ar:
	if num%4==0:
		f4 +=1
	elif num%2==0:
		even+=1
	else:
		odd+=1
if odd-f4 == 0:
	print "Yes"
elif odd-f4 <= 1 and even == 0:
	print "Yes"
else:
	print "No"

Solution (Python):
n = int(raw_input())
aa = map(int, raw_input().split())

div2 = 0
div4 = 0
for a in aa:
    if a % 4 == 0:
        div4 += 1
    elif a % 2 == 0:
        div2 += 1

if 0 < div2:
    div2 -= 1

if n - 1 <= div4*2 + div2:
    print 'Yes'
else:
    print 'No'

Solution (Python):
import sys

N = int(input())
ls = list(map(int, input().split()))
k = len(ls)
p = [ i for i in ls if (i%4) == 0]
j = [ i for i in ls if (i%4) != 0]
r = [ i for i in j if (i%2) == 0]

if(len(p) >= int(k/2)):
    print('Yes')
elif (len(p) >= (len(j) - len(r))):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
odd = 0
div2 = 0
div4 = 0
for l in L:
    if l % 2 != 0:
        odd += 1
    elif l % 4 == 0:
        div4 += 1
    else:
        div2 += 1

if N == 2:
    if odd == 2 or (odd == 1 and div2 == 1):
        print("No")
    else:
        print("Yes")
    exit()

if N == 3:
    if div4 >= 1:
        print("Yes")
    else:
        if odd == 0:
            print("Yes")
        else:
            print("No")
    exit()

if odd <= div4:
    print("Yes")
else:
    if div2 == 0 and odd - div4 == 1:
        print("Yes")
    else:
        print("No")

Solution (Python):

import random
n = int(input())
a = list(map(int, input().split()))
k1, k2, k4 = 0, 0, 0
for a_i in a:
    if a_i % 4 == 0:
        k4 += 1
    elif a_i % 2 == 0:
        k2 += 1
    else:
        k1 += 1
t = min(k1, k4)
k1 -= t
k4 -= t
result = k1 == 0 or (k1 == 1 and not k2)
print([ 'No', 'Yes' ][result])

Solution (Python):
from collections import Counter
N = int(input())
need = int(N // 2)
x = 0
y = 0
num = list(map(int,input().split()))
x = len(list(filter(lambda x: x%4 == 0,num)))
y = len(list(filter(lambda x: (x%4 != 0) and (x%2==0),num)))
if (x + (y // 2)) >= need:
	print("Yes")
else:
	print("No")

Solution (Python):


N = int(input())
A = list(map(int, input().split()))
t4 = 0
t2 = 0
for i in A:
    if i % 4 == 0:
        t4 += 1
    elif i % 2 == 0:
        t2 += 1
print(['No', 'Yes'][N//2<=(t4 + t2//2)])

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

for i in range(n):
    if a[i] % 4 == 0:
        a4 += 1
    elif a[i] % 2 == 0:
        a2 += 1

a2 //= 2

if (a4 + a2) >= n // 2:
    print("Yes")
else:
    print("No")

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

L = []
res = "No"

for a in A:
    if a % 4 == 0:
        L.append(4)
        continue
    elif a % 2 == 0:
        L.append(2)
        continue
    else:
        L.append(1)

if L.count(2) == 0:
    if L.count(1) <= (L.count(4) + 1):
        res = "Yes"
elif L.count(1) <= L.count(4):
    res = "Yes"

print(res)

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

count4 = 0
count2 = 0
for i in range(n):
    if a[i] % 4 == 0:
        count4 += 1
    elif a[i] % 2 == 0:
        count2 += 1

if (count4 >= n // 2) | ((count4 * 2 + count2) >= n):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
num = list(map(int, input().split()))
count = 0

for i in num:
    if i%4==0:
        N -= 2
    elif i%2==0:
        count += 1
if count>1:
    N = N - count + 1

if N > 1:
    print('No')
else:
    print('Yes')

Solution (Python):
import random

N = int(input())
num = list(map(int, input().split()))
count = 0

for i in num:
    if i%4==0:
        N -= 2
    elif i%2==0:
        count += 1
if count>1:
    N = N - count + 1

if N > 1:
    print('No')
else:
    print('Yes')

Solution (Python):


n=int(raw_input())
l=map(int,raw_input().split())
cnt1=cnt2=cnt4=0
for i in xrange(n):
 if l[i]%4==0:
  cnt4+=1
 elif l[i]%2==0:
  cnt2+=1
 else:
  cnt1+=1
if cnt4>=cnt1:
 print 'Yes'
elif cnt4==cnt1-1 and cnt2==0:
 print 'Yes'
else:
 print 'No'

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num_O=sum(map(lambda x:1 if not x%2 else 0,a))
num_T=sum(map(lambda x:1 if not x%4 else 0,a))
if(n//2-num_T-(num_O-num_T)//2<=0):
	print("Yes")
else:
	print("No")

Solution (Python):
n = int(raw_input())
a = [int(s) for s in raw_input().split(" ")]
four_multi = 0
no_four_multi_even = 0
odd = 0
for i in a:
    if i % 4 == 0:
        four_multi += 1
    elif i % 2 == 0:
        no_four_multi_even += 1
    else:
        odd += 1
if odd <= four_multi:
    print "Yes"
elif odd - 1 == four_multi and no_four_multi_even == 0:
    print  "Yes"
else:
    print "No"

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
p4=p2=p1=0
for i in a:
    if i%4==0:
        p4 += 1
    elif i%2==0:
        p2 += 1
    else:
        p1 += 1

if p2==0 and p1<= p4+1:
    print('Yes')

elif p2==0 and p1> p4+1:
    print('No')

elif p1 <= p4:
    print('Yes')

else:
    print('No')