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):
def judge(one, two, four):
	if two == 0 and one - four == 1: return 'Yes'
	elif one > four: return 'No'
	else: return 'Yes'	

N = int(raw_input())
a = map(int, raw_input().split())
one = 0
two = 0
four = 0

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

print judge(one, two, four)

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):
N = int(input())
a = list(map(int, input().split(' ')))

even = [i for i in a if i % 2 == 0 and i % 4 != 0]
odd = [i for i in a if i % 2 != 0]
by4 = [i for i in a if i % 4 == 0]
if len(odd) <= len(by4):
    print('Yes')
elif len(odd) - len(by4) == 1:
    if len(even) == 0:
        print('Yes')
    else: print('No')
else:
    print('No')

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

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

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

if div4 >= n//2:
    print("Yes")
else:
    if div2 >= n - div4 * 2:
        print("Yes")
    else:
        print("No")

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

one = sum([1 for a in src if a%2])
four = sum([1 for a in src if a%4==0])
two = N - one - four

print('Yes' if one <= four or (one == four+1 and two==0) else 'No')

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

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
a, b, c = 0, 0, 0

for i in l:
    if i % 4 == 0:
        c += 1
    elif i % 2 == 0:
        b += 1
    else:
        a += 1

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

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
a, b, c = 0, 0, 0

for i in l:
    if i % 4 == 0:
        c += 1
    elif i % 2 == 0:
        b += 1
    elif not i % 2 == 0:
        a += 1

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

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
a, b, c = 0, 0, 0

for i in l:
  if i % 4 == 0:
    c += 1
  elif i % 2 == 0:
    b += 1
  elif not i % 2 == 0:
    a += 1

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

Solution (Python):
N=int(input())
s,t,u=0,0,0
for i in list(map(int,input().split())):
    if i%4==0:
        s+=1
    elif i%2==0:
        t+=1
    else:
        u+=1
if u-s<=1 and (t==0 or u-s<1):
    print("Yes")
else:
    print("No")

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

Solution (Python):
n = int(input())
a, b = 0, 0
for x in input().split():
    x = int(x)
    if x % 4 == 0: a += 1
    elif x % 2 == 0: b += 1
if a * 2 + b // 2 * 2 + 1 >= n: print('Yes')
else: print('No')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
bai4 = 0
bai2 = 0
kisuu = 0
for i in a:
    if i%4 == 0:
        bai4 += 1
    elif i%2 == 0:
        bai2 += 1
    else:
        kisuu += 1
if N%2 == 0:
    if kisuu <= bai4:
        print("Yes")
    else:
        print("No")
else:
    if min(kisuu,N//2) <= bai4:
        print("Yes")
    else:
        print("No")

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

fourEven = 0
odd = 0
for num in n:
    if num % 4 == 0:
        fourEven += 1
    elif num % 2 == 1:
        odd += 1

if len(n) // 2 <= fourEven or odd <= fourEven:
    print('Yes')
else:
    print('No')

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

fourEven = 0
odd = 0
otherEven = 0
for num in n:
    if num % 4 == 0:
        fourEven += 1
    elif num % 2 == 1:
        odd += 1
    else:
        otherEven += 1



if len(n) // 2 <= fourEven:
    print('Yes')
elif odd <= fourEven:
    print('Yes')
else:
    print('No')

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

fourEven = 0
odd = 0
otherEven = 0
for num in n:
    if num % 4 == 0:
        fourEven += 1
    elif num % 2 == 1:
        odd += 1
    else:
        otherEven += 1



if len(n) // 2 <= fourEven:
    print('Yes')
elif odd <= fourEven and otherEven >= 0:
    print('Yes')
else:
    print('No')

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

Solution (Python):
n = int(input())
num = list(map(int,input().split()))
c2,c4,ce=0,0,0
for i in range(n):
  if num[i]%4 ==0:
    c4 += 1
  elif num[i]%2 ==0:
    c2 = 1
  else:
    ce +=1
if ce ==0:
  print('Yes')
elif c2 + ce <= c4 +1:
  print('Yes')
else:
  print('No')

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

Solution (Python):


n = int(input())
n4 = 0
n2 = 0
n1 = 0
for x in input().split(" "):
    x = int(x)
    if x%4==0:
        n4 += 1
    elif x%2==0:
        n2 += 1
    else:
        n1 += 1

if n2>1:
    n2 = 1

if n1+n2-1<=n4:
    print("Yes")
else:
    print("No")

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

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

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

if (a1+a4)==N:
  if a4+1>=a1:
    print("Yes")
  else:
    print("No")
else:
  if a4>=a1:
    print("Yes")
  else:
    print("No")

Solution (Python):
from collections import Counter

N = int(input())
b = [int(ai)%4 for ai in input().split()]

c = Counter(b)
n1 = c[1] + c[3]
n2 = c[2]
n4 = c[0]

if (n2 == 0 or n1 <= n4) and (n2 != 0 or n1 <= n4+1):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
P=0
Q=0
R=0
for i in range(N):
    if a[i]%4==0:
        P+=1
    elif a[i]%4==2:
        Q+=1
    else:
        R+=1
if (Q==0 and R>P+1) or (Q!=0 and R>P):
    print("No")
else:
    print("Yes")

Solution (Python):
N = int(input())
list1 = list(map(int,input().split()))		
no1 = 0
no2 = 0
no3 = 0
for z in range(N):
  if list1[z] % 4 == 0:
    no1 += 1
  elif list1[z] % 2 == 0:
    no2 += 1
  else:
    no3 += 1


if no2 >= 1:
  no3 += 1

if (no1 + 1) >= no3:
  print("Yes")
else:
  print("No")

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

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

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

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

if (x[1]==0 and x[2] >= x[0]-1 and x[2]>0) or x[2] >= x[0] or x[0]==0:
  print('Yes')
else:
  print('No')

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


cnt2 = 0
cnt4 = 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 = map(int, input().split())

num_d = {}

for num in a:
    num_d.setdefault(num, 0)
    num_d[num] += 1

quad = 0
doub = 0
odd = 0
for k, v in num_d.items():
    if k % 4 == 0:
        quad += v
    elif k % 4 != 0 and k % 2 == 0:
        doub += v
    else:
        odd += v

if quad >= (odd + doub) - 1:
    print("Yes")
elif doub % 2 == 0 and quad >= odd - 1:
    print("Yes")
elif doub % 2 != 0 and quad >= odd - 1 and (quad - odd) >= 0:
    print("Yes")
else:
    print("No")

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

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

b = [0,0,0,0]

for x in ls:
    if x % 4 == 0:
        b[3] += 1
    elif x % 2 == 0:
        b[1] += 1
    else:
        b[0] += 1

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

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

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

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

Solution (Python):
from collections import Counter
n = int(input())

def foo(a):
    d, m = divmod(a, 2)
    if m:
        return 0
    elif d%2 == 0:
        return 2
    else:
        return 1

cnt = Counter(map(foo, (map(int, input().split()))))

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

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

Solution (Python):


import sys

N = int(sys.stdin.readline())
a = [int(w) for w in sys.stdin.readline().split()]
if len(a) != N: raise

n4 = len([n for n in a if n % 4 == 0])
n2 = len([n for n in a if n % 2 == 0 and n % 4 != 0])
n1 = len([n for n in a if n % 2 != 0])

if n2 > 0: n1 += 1
answer = (n1 <= n4 + 1)

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

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

zero = 0
two = 0
four = 0

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

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

Solution (Python):

input()
xs = map(int, input().split())

n1, n2, n4 = 0, 0, 0

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

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

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

num2 = 0
num4 = 0
numo = 0

for a in A:
    if a % 4 == 0:
        num4 += 1
    elif a % 2 == 0:
        num2 += 1
    else:
        numo += 1

if num2 == 0:
    if num4 + 1 >= numo:
        print("Yes")
    else:
        print("No")
else:
    if num4 >= numo:
        print("Yes")
    else:
        print("No")

Solution (Python):

input()
vals    = input()
vals    = vals.split()
vals    = list(map(lambda v:int(v), vals))


kisu    = 0
div4    = 0
div2    = 0

for e in (vals):
    if e % 4 == 0:
        div4    += 1
    elif e % 2 == 1:
        kisu    += 1
    else:
        div2    += 1

if div4 >= kisu:
    print("Yes")
elif div4 == kisu - 1 and len(vals) == div4 + kisu:
    print("Yes")
elif div2 == len(vals):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"

Solution (Python):
n = input()
ain = input()
a = ain.split()
count = 0.0

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

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

Solution (Python):
import math
 
num = int(input())
value = input().split()
value = [int(x) for x in value]
 
res = 0
two = 0
for i in value:
    if i % 4 == 0:
        res += 1
    elif i % 2 == 0:
        two += 1
 
if two > 0:
    print("Yes" if res >= math.ceil((len(value)-two)/2) else "No")
else:
    print("Yes" if res >= math.floor(len(value)/2) else "No")

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1




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

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

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

if count4==0:
    if count2-count2%2>=n:
        print("Yes")
    else:
        print("No")

else:
    if count4*2+1+count2-count2%2>=n:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
c = [0, 0, 0]  

for i in map(int, input().split()):
    if i % 4 == 0:
        c[2] += 1
    elif i % 2 == 0:
        c[1] += 1
    else:
        c[0] += 1

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

Solution (Python):
N = int(input())
c = [0, 0, 0]  

for i in map(int, input().split()):
    if i % 4 == 0:
        c[2] += 1
    elif i % 2 == 0:
        c[1] += 1
    else:
        c[0] += 1

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

Solution (Python):
N = input()
A = input()
a = A.split(' ')

si = []
for i in a:
    j = int(int(i) % 4)
    si.append(j)

kazu = []
for i in range(4):
    j = si.count(i)
    kazu.append(j)

x = int(int(kazu[2]) % 2)
if x == 0:
    y = int(int(kazu[1]) + int(kazu[3]) - 1)
else:
    y = int(int(kazu[1]) + int(x) + int(kazu[3]) - 1)

if int(kazu[0]) >= int(y):
    print('Yes')
else:
    print('No')

Solution (Python):



N  = int(input())
a = list(map(int,input().split()))
n_4 ,n_2 ,n_1 = 0,0,0
ans = ""

for i in range(N):
    if a[i] %4 ==0:
        n_4 += 1
    elif a[i] %4 == 2:
        n_2 += 1
    else :
        n_1 += 1
if n_1 < n_4 + 1:
    ans = "Yes"
elif (n_1 == n_4 + 1)and(n_2 == 0):
    ans = "Yes"
elif n_1 == 0:
    ans = "Yes"
else :
    ans ="No"

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
count4 = 0
count2 = 0
countelse = 0
for i in range(n):
	if a[i] % 4 == 0:
		count4 += 1
	if a[i] % 2 == 0:
		count2 += 1
	else:
		countelse += 1
count2 = count2 - count4
if n % 2 != 0:
	if count4 < (countelse - 1):
		print('No')
	else:
		print('Yes')
else:
	if count4 < countelse:
		print('No')
	else:
		print('Yes')

Solution (Python):
N =input()
a =input().split()
b,c,d =0,0,0
for i in range(0,int(N)):
    hoge = int(a[i])%2
    if hoge ==0:
        b =b+1
for i in range(0,int(N)):
    hoge = int(a[i])%4
    if hoge ==0:
        c =c+1
d = b-c
if d ==0:
    if c-(int(N)-b)+1>=0:
        print('Yes')
    else:
        print('No')
else:
    if c-(int(N)-b)>=0:
        print('Yes')
    else:
        print('No')

Solution (Python):

"""
http://abc069.contest.atcoder.jp/tasks/arc080_a

"""


def solve(data):
    l_data = len(data)
    mo4s = [x for x in data if x%4 == 0] 
    l_mo4s = len(mo4s)
    odds = [x for x in data if x%2 == 1]
    l_odds = len(odds)
    l_evens = l_data - l_odds - l_mo4s
    
    
    

    if l_odds > (l_mo4s + 1):
        return 'No'
    if (l_odds > l_mo4s) and (l_data > (l_mo4s + l_odds)):
        return 'No'
    return 'Yes'


def main():
    N = int(input())
    data = [int(x) for x in input().split()]
    result = solve(data)
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    f, o = 0, 0
    for a in a_list:
        f += a % 4 == 0
        o += a % 2 != 0

    if f >= (N // 2) or f >= o:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    f, t, o = 0, 0, 0
    for a in a_list:
        if a % 4 == 0:
            f += 1
        elif a % 2 == 0:
            t += 1
        else:
            o += 1

    if f >= (N // 2) or f >= o:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

a4 = 0
aodd = 0

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

x = 0

if a4 >= n // 2:
    x += 1
elif aodd <= a4:
    x += 1

print('Yes' if x == 1 else 'No')

Solution (Python):
def judge_type(x):
    if x % 4 == 0:
        return 4
    elif x % 2 == 0:
        return 2
    else:
        return 1


def solve(): 
    N = int(input())
    a = list(map(int, input().split(" ")))
    cnt_odd = 0
    cnt_2 = 0
    cnt_4 = 0
    flag_2 = False

    for i in a:
        if judge_type(i) == 1:
            cnt_odd += 1
        elif judge_type(i) == 2:
            cnt_2 += 1
            flag_2 = True
        elif judge_type(i) == 4:
            cnt_4 += 1

    if flag_2:
        if cnt_odd <= cnt_4:
            print("Yes")
        else:
            print("No")
    else:
        if cnt_odd <= cnt_4 + 1:
            print("Yes")
        else:
            print("No")


solve()

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

num4 = 0
num2 = 0
num1 = 0
for aa in a:
    if aa % 4 == 0:
        num4 += 1
    elif aa % 2 == 0:
        num2 += 1
    else:
        num1 += 1

if num2 == 0:
    if num1 <= num4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if num1 <= num4:
        print('Yes')
    else:
        print('No')

Solution (Python):


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

m4 = 0
m2 = 0
k = n/2
flg = 1
for i in a:
    if(i%4 == 0):
        m4 += 1
    elif(i%2 == 0):
        m2 += 1
if(m4 >= k):
    print('Yes')
    flg = 0
else:
    if(n%2 == 0):
        if(m2 >= (k-m4)*2):
            print('Yes')
            flg = 0
    else:
        if(m2 >= (k-m4)*2+1):
            print('Yes')
            flg = 0
if(flg):
    print('No')

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

b0, b1, b2 = 0,0,0

for i in a:
    if i % 2 != 0:
        b0 += 1
    else:
        if i % 4 != 0:
            b1 += 1
        else:
            b2 += 1

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

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

b0, b1, b2 = 0,0,0 

for i in a:
    if i % 2 != 0:
        b0 += 1
    else:
        if i % 4 != 0:
            b1 += 1
        else:
            b2 += 1
            
if b1 == 0:
    if b2 + 1 >= b0:
        print('Yes')
    else:
        print('No')
else:
    b0 += 1
    if b2 + 1 >= b0:
        print('Yes')
    else:
        print('No')

Solution (Python):
N = input()
a = map(int, raw_input().split())
a1, a2, a4 = [], [], []
for i in range(N):
    if a[i] % 4 == 0:
        a4.append(a[i])
    elif a[i] % 2 == 0:
        a2.append(a[i])
    else:
        a1.append(a[i])
if N % 2 == 0:
    if len(a1) <= len(a4):
        print "Yes"
    else:
        print "No"
else:
    if len(a1) <= len(a4):
        print "Yes"
    elif len(a1) == len(a4) + 1:
        print "Yes" if (len(a2) % 2 == 0) else "No"
    else:
        print "No"

Solution (Python):
def main():
    _ = input()
    
    b0, b1, b2 = 0, 0, 0
    for c in input().split():
        n = int(c)
        if n % 4 == 0: b2 += 1
        elif n % 2 == 0: b1 += 1
        else: b0 += 1

    if b1 == 0:
        if b0 < b2 + 2:
            print("Yes")
        else:
            print("No")
    else:
        if b0 < b2 + 1:
            print("Yes")
        else:
            print("No")
            

if __name__ == "__main__":
    main()

Solution (Python):
def main(N, aa):
    """
    a_i * a_(i+1) = 4k
        i=2n and i+1=2m
        i=4n or  i+1=4m

    half: 4m -> ok
    all: 2n -> ok

    example5
        2 7 1 8 2 8
          -     -
        2 2 1 8 7 8
    all2を作成
    残りhalfのパターン

    example2
        1 2 3 4
        2 1 3 4
          1 3 4

        all2, 最後の１つは２＊２にならないので以下でフォロー
        2, 4m, x, 4m
        2, 4m, x, 4m, x
    """
    n_m2 = 0
    n_m4 = 0
    n_m2_notm4 = 0
    for a in aa:
        is_m2 = a % 2 == 0
        is_m4 = a % 4 == 0

        n_m2 += int(is_m2)
        n_m4 += int(is_m4)
        n_m2_notm4 += int(is_m2 and not is_m4)

    if n_m2_notm4 == 0 and n_m4 >= N // 2:
        return "Yes"
    else:
        rest = N - n_m2_notm4 + 1
        if n_m4 >= rest // 2:
            return "Yes"
        else:
            return "No"


if __name__ == '__main__':
    N = int(input())
    aa = map(int, input().split())

    print(main(N, aa))

Solution (Python):
def main(N, aa):
    """
    a_i * a_(i+1) = 4k
        i=2n and i+1=2m
        i=4n or  i+1=4m

    half: 4m -> ok
    all: 2n -> ok

    example5
        2 7 1 8 2 8
          -     -
        2 2 1 8 7 8
    all2を作成
    残りhalfのパターン

    example2
        1 2 3 4
        2 1 3 4
          1 3 4

        all2, 最後の１つは２＊２にならないので以下でフォロー
        2, 4m, x, 4m
        2, 4m, x, 4m, x
    """
    n_m2 = 0
    n_m4 = 0
    n_m2_notm4 = 0
    for a in aa:
        is_m2 = a % 2 == 0
        is_m4 = a % 4 == 0

        n_m2 += int(is_m2)
        n_m4 += int(is_m4)
        n_m2_notm4 += int(is_m2 and not is_m4)

    if n_m2 == N:
        return "Yes"
    elif n_m2_notm4 == 0 and n_m4 >= N // 2:
        return "Yes"
    else:
        rest = N - n_m2_notm4 + 1
        if n_m4 >= rest // 2:
            return "Yes"
        else:
            return "No"


if __name__ == '__main__':
    N = int(input())
    aa =map(int, input().split())

    print(main(N, aa))

Solution (Python):
N=input()

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


cnt4=0
cnt2=0
kisuu=0
for i in range(len(a)):
	
	if a[i]%4==0:
		cnt4+=1
	elif a[i]%4!=0 and a[i]%2==0:
		cnt2+=1
	elif a[i]%2==1:
		kisuu+=1






if cnt4>0 and cnt2==0 and kisuu==0:
	print 'Yes'
elif cnt4==kisuu:
	print 'Yes'
elif cnt4+1==kisuu and cnt2==0:
	print 'Yes'
else:
	print 'No'

Solution (Python):
N = int(input())
al = [int(an) for an in input().split()]
a = [ "4" if al[i]%4==0 else "k" if al[i]%2!=0 else "g" for i in range(N)]
if a.count("k") == a.count("4") or len(a) == a.count("g") + a.count("4"):
	print("Yes")
elif (a.count("k") - 1) == a.count("4")  and a.count("g")==0:
	print("Yes")
else:
	print("No")

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

num4 = 0
num2 = 0
num1 = 0

for i in range(N):
    if a[i] % 4 == 0:
        num4 += 1
    elif a[i] % 2 == 0:
        num2 += 1
    else:
        num1 += 1

if (num1 <= num4 + 1) & (num2 == 0):
    print("Yes")
elif (num1 <= num4) & (num2 != 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')

Solution (Python):
n,*A=map(int,open(0).read().split());p=sum(a%2<1for a in A);q=sum(a%4<1for a in A);print("Yes"*(q==p>n-p-2or n-p<=q)or"No")

Solution (Python):
n,*A=map(int,open(0).read().split())
C=[0]*3
for a in A:
    for i in range(2,-1,-1):
        if a%2**i == 0:
            C[i] += 1
            break
print("Yes"*(C[0]<=C[2]or (C[0]==C[2]+1 and C[1]==0))or"No")

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

o=0
f=0
for i in a:
    if i%4==0:
        f+=1
    elif i%2!=0:
        o+=1

if len(a)==f+o:
    f+=1

print("Yes" if f>=o else "No")

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

num4 = 0
num2 = 0
for ai in a:
    if ai % 4 == 0:
        num4 += 1
    elif ai % 2 == 0:
        num2 += 1
        
if num4*2 + num2 >= N or num4*2 + 1 >= N:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
Nodd = len([x for x in a if x%2 == 1])
Neven = len([x for x in a if x%2 == 0])
Nfour = len([x for x in a if x%4 == 0])
if Nodd <= Nfour or (Nodd+Nfour==N and Nodd-Nfour==1):
    print("Yes")
else:
    print("No")

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    div4 = len(list(filter(lambda x: x % 4 == 0, a)))
    div2 = len(list(filter(lambda x: (x % 2 == 0 and x % 4 != 0), a)))
    div1 = n - div4 - div2
    if(div4 + 1 < div1 + bool(div2)):
        print("No")
    else:
        print("Yes")

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

one_count = 0
four_count = 0
two_count = 0
result = 'No'

for i in a_list:
    if i % 2 == 1:
        one_count += 1
    elif i % 4 == 0:
        four_count += 1
    else:
        two_count += 1

if one_count <= four_count or (one_count - 1  == four_count and two_count == 0):
    result = 'Yes'

print(result)

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

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

k = len(list(filter(lambda x: x%4 == 0, a)))
j = len(list(filter(lambda x: x%2 == 0, a)))-k
i = len(a)-j-k

if (j > 0) and (i <= k):
    print("Yes")
elif (j == 0) and (i-1 <= k):
    print("Yes")
else:
    print("No")

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

f,e,d = 0,0,0

for a in A:
    x = a % 4
    if(x==0):
        f = f+1
    elif(x==2):
        e = e+1
    else:
        d = d+1
if(e>0):
    d = d+1
if(f >= d-1):
    print("Yes")
else:
    print("No")

Solution (Python):


N=int(input())

mozir=input()
hyo=mozir.split(' ')
a=[int(mono) for mono in hyo]

mobius=0
huckel=0
ungerade=0
for mono in a:
    if mono % 2 == 0:
        if mono % 4 == 0:
            mobius+=1
        else:
            huckel+=1
    else:
        ungerade+=1



if mobius >= N // 2:
    ans=True
else:
    
    
    hashi=mobius*2-1

    rightend=N-huckel
    if rightend-hashi<=1:
        ans=True
    else:
        ans=False

if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
num = input()
list = map(int, raw_input().split())
count1 = 0
count4 = 0
for x in list:
    if x % 2 == 1:
        count1 = count1 + 1
    if x % 4 == 0:
        count4 = count4 + 1
if count1 > count4 and num > 3 and count1 + count4 < num:
    print("No")
elif count1 > count4 + 1 and num > 3 and count1 + count4 == num:
    print("No")
elif num == 2 and count4 - count1 < 0:
    print("No")
elif num == 3 and count4 == 0 and count1 > 0:
    print("No") 
else:
    print("Yes")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
p=0
f=0
for ai in a:
    if ai%2==1:
        p+=1
    else:
        if ai/2%2==0:
            f+=1
if p==0:
    print('Yes')
elif p>f:
    if n%2==1 and 2*f+1==n:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
a4=0
a2=0
a1=0
for a in arr:
    if a%4==0:
        a4+=1
    elif a%2==0:
        a2+=1
    else:
        a1+=1
if a1==0:
    print("Yes")
elif a2==0:
    if a1<=a4+1:
        print("Yes")
    else:
        print("No")
else:
    if a1<=a4:
        print("Yes")
    else:
        print("No")

Solution (Python):
n=input()
l=map(int,raw_input().split())
f=0
t=0
o=0
for i in l:
    if i%4==1 or i%4==3:
        o+=1
    elif i%4==2:
        t+=1
    else:
        f+=1
if t==0:
    if f>=n/2:
        ans="Yes"
    else:
        ans="No"
else:
    if o<=f:
        ans="Yes"
    else:
        ans="No"
print ans

Solution (Python):

N = int(input())
factor = 0
a = list(map(int, input().split()))
b = [ tmp for tmp in a if tmp%4 == 0 ]
c = [ tmp for tmp in a if tmp%2 == 0 ]
d = [ tmp for tmp in a if tmp%2 != 0 ]
if len(c)-len(b) != 0 and len(b)-len(d) >= 0:
    print("Yes")
elif len(c)-len(b) == 0 and len(b)+1 >= len(d):
    print("Yes")
else:
    print("No")