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

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

if two:
    if one <= four:
        print("Yes")
    else:
        print("No")
else:
    if one - 1 <= four:
        print("Yes")
    else:
        print("No")

Solution (Python):

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist

def submit():
    n, alist = read_input()

    four_multiple = sum([1 for a in alist if a % 4 == 0])
    two_multiple = sum([1 for a in alist if a % 4 != 0 and a % 2 == 0])

    if n // 2 <= four_multiple:
        print('Yes')
        return

    n -= 2 * four_multiple
    if n <= two_multiple:
        print('Yes')
        return

    print('No')




if __name__ == '__main__':
    submit()

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

c2 = 0
c4 = 0
for a in A:
    if a % 4 == 0:
        c4 += 1
    elif a % 2 == 0:
        if c2 == 1:
            c4 += 1
            c2 = 0
        else:
            c2 += 1
if c4 >= N//2:
    print('Yes')
else:
    print('No')

Solution (Python):
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
    else:
        continue
if(N%2==0):
    if(F*2+T)>=N:
        print("Yes")
    else:
        print("No")
else:
    if(F*2+1+T)>=N:
        print("Yes")
    else:
        print("No")

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

MOD2 = 0
MOD4 = 0

for i in a:
    if i % 4 == 0:
        MOD4 += 1
    elif i % 2 == 0:
        MOD2 += 1

if MOD4 == 0:
    if N == MOD2:
        print('Yes')
    else:
        print('No')
else:
    if MOD2 >= 1:
        MOD2 -= 1
    if (N-MOD2) // 2 <= MOD4:
        print('Yes')
    else:
        print('No')

Solution (Python):
_ = int(input())
an = list(map(int,input().split()))

odd = list(filter((lambda x:x%2==1),an))
div4 = list(filter((lambda x:x%4 ==0),an))
div2 = set(an).difference(set(odd)).difference(set(div4))
if len(div2) == 0:
  div4.append(0)
if len(odd) <= len(div4):
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
flg = 0
ct_2, ct_4 = 0, 0
for i in a:
    if i % 4 == 0:
        ct_2 += 1
        ct_4 += 1
    elif i % 2 == 0:
        ct_2 += 1

if ct_4 >= N//2:
    flg = 1
else:
    if ct_2 >= N-ct_4:
        flg = 1

if flg == 1:
    print('Yes')
else:
    print('No')

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

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

n1 = 0
n2 = 0
n4 = 0

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

if n1 <= n4:
    ans = 'Yes'
else:
    if n1 == n4 + 1 and n2 == 0:
        ans = 'Yes'
    else:
        ans = 'No'

print(ans)

Solution (Python):
import itertools

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

def calc_two_factor_count(a_i):
  if a_i % 2 == 1:
    return 0
  elif a_i / 2 % 2 == 1:
    return 1
  else:
    return 2

aggregated_a = {two_factor_count: sum(1 for _ in iter) for (two_factor_count, iter) in itertools.groupby(sorted(a, key = calc_two_factor_count), key = calc_two_factor_count)}
b = [aggregated_a[i] if i in aggregated_a else 0 for i in range(3)]

print("Yes" if (n % 2 == 0 and b[0] <= n / 2 and b[2] >= b[0]) or (n % 2 == 1 and b[0] <= (n - 1) / 2 and b[2] >= b[0]) or (n % 2 == 1 and b[0] == (n + 1) / 2 and b[2] == (n - 1) / 2) else "No")

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

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


odd = []
even2 = []
even4 = []

for i in a:
  if i % 4 == 0:
    even4.append(i)
  elif i % 2 == 0:
    even2.append(i)
  else:
    odd.append(i)
    
    

if len(odd) <= len(even4):
  print("Yes")
elif len(odd) == len(even4) + 1:
  if len(even2) == 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

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

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

Solution (Python):
N=int(input())
onetwofour=[0,0,0]
ans="No"
for i in [int(j) for j in input().split()]:
    if i%4==0:
        onetwofour[2]+=1
    elif i%2==0:
        onetwofour[1]+=1
    else:
        onetwofour[0]+=1
if onetwofour[2]>=onetwofour[0]:
    ans="Yes"
elif onetwofour[1]==0 and onetwofour[2]==onetwofour[0]-1:
    ans="Yes"
print(ans)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=I()
A=LI()


f=[]
odds=[]
t=[]
for n in A:
    if n%4==0:
        f.append(n)
    elif n%2!=0:
        odds.append(n)
    else:
        t.append(n)
if len(odds)==0:
    print('Yes')
elif len(f) < len(odds)-1:
    print('No')
else:
    if len(odds) - 1 == len(f):
        if len(t)> 0:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

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

time1, time2, time4 = 0, 0, 0
for item in a:
    if item % 4 == 0:
        time4 += 1
    elif item % 2 == 0:
        time2 += 1
    else:
        time1 += 1

if (time1 + time2 % 2 + time4) % 2 == 1:
    time4 += 1

if time1 + time2 % 2 > time4:
    print("No")
else:
    print("Yes")

Solution (Python):
import math
n=int(input())
a=[int(i) for i in input().split()]
odd=0
two=0
four=0
for i in a:
    if i%2==0:
        i=i//2
        if i%2==0:
            four+=1
        else:
            two+=1
    else:
        odd+=1
res=False
if two==0:
    if odd<=four+1:
        res=True
elif odd<=four:
    res=True
print("Yes" if res else "No")

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




if two==0:
    if zero<=four+1:
        print("Yes")
    else:
        print("No")
else:
    
    if zero<=four:
        print("Yes")
    else:
        print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
even_list = [i for i in a if i % 2 == 0]
odd_list = [i for i in a if i % 2 != 0]
four_list = [i for i in even_list if i % 4 == 0]
two_idx = n // 2
if len(four_list) >= two_idx:
  print('Yes')
elif n - 2 * len(four_list) == len(even_list) - len(four_list):
  print('Yes')
else:
  print('No')

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
a=0;b=0;c=0
for i in l:
    if i%4==0:
        a+=1
    elif i%4==2:
        b+=1
    else:
        c+=1
if b==0:
    if a>=c-1:
        bool=True
    else:
        bool=False
else:
    c+=1
    if a>=c-1:
        bool=True
    else:
        bool=False
if bool:
    print('Yes')
else:
    print('No')

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
n = ip()                                     

a = [int(i) for i in input().split()]        







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

if one-1 > four:j(0)
else :
    if one==four:leftover=1
    if two%2:
        if leftover==0:
            j(0)
        else:j(1)
    else: j(1)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if a[i]%4==0:
        a[i]=4
    elif a[i]%2==0:
        a[i]=2
    else:
        a[i]=0
from collections import Counter
C = Counter(a)
if C[4]>=C[0]+C[2]%2-1:
    print('Yes')
else:
    print('No')

Solution (Python):
a1,a2,a4=0,0,0

for i in range(1):
    
    n=int(input())
    y=map(int,input().split())
    for x in y:
        
        if x%4==0:
            a4+=1
        elif x%2==0:
            a2=1
        else:
            a1+=1
ans='Yes' if a1+a2<=a4+1 else 'No'
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
f0, f1, f2 = 0, 0, 0
for i in range(N):
    if a[i] % 4 == 0:
        f2 += 1
    elif a[i] % 2 == 0:
        f1 += 1
    else:
        f0 += 1
if f1:
    if f0 <= f2:
        print('Yes')
    else:
        print('No')
else:
    if f0 <= f2 + 1:
        print('Yes')
    else:
        print('No')

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

for ai in a:
    if ai % 4 == 0:
        x += 1
    elif ai % 2 == 1:
        y += 1
if x >= y or (x == y - 1 and x + y == N):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
for i in range(N):
    ai = a[i]
    cnt = 0
    while ai > 1:
        if ai %2 == 1:
            break
        else:
            ai=ai//2
            cnt += 1
    b[i] = (cnt,a[i])
b.sort()
c=[0]*(N)
for i in range(N):
    if i%2 == 0:
        c[i] = b[i][1]
    else:
        c[i] = b[N-i][1]
for i in range(N-1):
    if c[i]*c[i+1]%4 !=0:
        print("No")
        exit()
    else:
        continue
print("Yes")

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

if b >= a:
    print("Yes")
elif c == 0 and a - b ==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

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

    if n4 >= N//2:
        return 'Yes'
    elif n2 >= 2 and n4 >= (N - n2 + 1) // 2:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    print(main())

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
not_two=0
yes_four=0
for i in a:
  if i%2!=0:
    not_two+=1
  if i%4==0:
    yes_four+=1
if yes_four-not_two>=0:
  print('Yes')
elif yes_four+not_two==n and yes_four-not_two==-1:
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]
b = []
for x in a:
    num = 0
    if x%2 == 0:
        x = x//2
        num += 1
        if x%2 == 0:
            num += 1
    b.append(num)
if b.count(0) <= b.count(2):
    print('Yes')
else:
    if b.count(0) == b.count(2)+1 and len(b) == b.count(0)+b.count(2):
        print('Yes')
    else:
        print('No')

Solution (Python):
from collections import Counter
N = int(input())
alist = list(map(int,input().split()))
zero , one , two = 0 , 0 , 0
for a in alist:
    if a % 4 == 0:
        two += 1
    elif a % 2 == 0:
        one += 1
    else:
        zero += 1
def func(zero, one, two):
    if zero == 0:
        return True
    if one == 0 :
        if (zero <= (two + 1)):
            return True
        else:
            return False
    if (zero + 1 )  <= (two + 1): 
        return True
    return False
print("Yes" if func(zero , one, two) else "No")

Solution (Python):
N = int(input())
a = list(map(int, 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 * 2 + 1 >= N or c4 * 2 + c2 >= N:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
num_4 = len([4 for a_ in a if (a_ % 4 == 0)])
num_2 = len([2 for a_ in a if (a_ % 4 == 2)])
num_0 = n - num_4 - num_2
if ((num_4 + num_2 > 0) & ((num_4 + 1 == num_0) & (num_2 == 0)) | (num_0 - num_4 <= 0)):
    print("Yes")
else:
    print("No")

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


def main():
    two = an.count(2)
    four = an.count(0)
    other = N - two - four

    if 0 < two:
        other += 1

    print("Yes" if other - 1 <= four else "No")
    return


main()

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


def main():
    ar = [0] * 3
    for ai in an:
        if ai % 4 == 0:
            ar[2] += 1
        elif ai % 2 == 0:
            ar[1] += 1
        else:
            ar[0] += 1

    if 0 < ar[1]:
        ar[0] += 1

    print("Yes" if ar[0] - 1 <= ar[2] else "No")
    return


main()

Solution (Python):
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]
b = []
for x in a:
    num = 0
    if x%2 == 0:
        x = x//2
        num += 1
        if x%2 == 0:
            num += 1
    b.append(num)
if b.count(0) <= b.count(2):
    print('Yes')
else:
    if b.count(0) == b.count(2)+1 and len(b) == b.count(0)+b.count(2):
        print('Yes')
    else:
        print('No')

Solution (Python):
def four_adjacent(N: int, A: list)->bool:
    n2, n4 = 0, 0
    for a in A:
        if a % 4 == 0:
            n4 += 1
        elif a % 2 == 0:
            n2 += 1
    return N//2 == n4 or N <= 2*n4 + n2


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    yes = four_adjacent(N, A)
    print('Yes' if yes else 'No')

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

def div2(a):
  if a%2 ==1:
    return 0
  if (a//2)%2==1:
    return 1
  else:
    return 2

_A = [div2(a) for a in A]

if _A.count(1):
  if _A.count(0) <= _A.count(2):
    print('Yes')
  else:
    print('No')
else:
  if _A.count(0) <= _A.count(2) +1:
    print('Yes')
  else:
    print('No')

Solution (Python):
N=int(input())
count_4=0
count_2=0
a_list=list(map(int, input().split()))
for i in range(N):
    if a_list[i]%4==0:
        count_4=count_4+1
    elif a_list[i]%2==0:
        count_2=count_2+1

need_count=N//2

if need_count<=count_4+count_2//2:
    print("Yes")
else:
    print("No")

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

b = [i%4 for i in a]

b4 = b.count(0)
b2 = b.count(2)
b1 = n - b4 - b2

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

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

cnt_4 = a.count(0)
cnt_2 = a.count(2)
cnt_0 = n - cnt_4 - cnt_2

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

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

cnt_4 = sum(i%4==0 for i in a)
cnt_2 = sum(i%2==0 for i in a) - cnt_4
cnt_0 = n - cnt_4 - cnt_2

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

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

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

if cnt_2 == 0:
  if cnt_4 >= cnt_0-1:
    print('Yes')
  else:
    print('No')
else:
  if cnt_4 >= cnt_0:
    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] % 4 == 2:
        two += 1
    else:
        pass

if four == 0:
    if two == N:
        print('Yes')
    else:
        print('No')
else:
    if two <= 1:
        if N <= 2*four+1:
            print('Yes')
        else:
            print('No')
    else:
        if N <= 2*four+two:
            print('Yes')
        else:
            print('No')

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X = Counter([4 if a % 4 == 0 else (2 if a % 2 == 0 else 1) for a in A])
for x in (1, 2, 4):
    if x not in X:
        X[x] = 0
if X[4] + 1 < X[1]:
    print("No")
    exit()
if X[4] + 1 == X[1] and X[2] != 0:
    print("No")
    exit()
print("Yes")

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

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

cnt_4=0

cnt_2=0

for i in A:
    if i%4==0:
        cnt_4+=1
    elif i%2==0:
        cnt_2+=1


if cnt_4>=(n//2):
    print('Yes')
else:
    if 2*cnt_4+cnt_2>=n:
        print('Yes')
    else:
        print('No')

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

if cnt[1]>0:
    cnt[1]-=1
    bef=1
elif cnt[2]>0:
    cnt[2]-=1
    bef=2
else:
    cnt[4]-=1
    bef=4

flag=True
for i in range(N-1):
    if bef==1:
        if cnt[4]==0:
            flag=False
            break
        cnt[4]-=1
        bef=4
    elif bef==4:
        if cnt[1]>0:
            cnt[1]-=1
            bef=1
        elif cnt[2]>0:
            cnt[2]-=1
            bef=2
        else:
            cnt[4]-=1
            bef=4
    elif bef==2:
        if cnt[2]>0:
            cnt[2]-=1
            bef=2
        else:
            if cnt[4]==0:
                flag=False
                break
            cnt[4]-=1
            bef=4
if flag:print('Yes')
else:print('No')

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
a1=a2=0
for x in l:
  if x%4==0:
    a1+=1
  elif x%2==0:
    a2+=1
if a1>0:
  a1-=1
  n-=3
  if a2>0:
    a2-=1
if a1*2+a2<n:
  print('No')
else:
  print('Yes')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A_2 = [a%2 for a in A]
A_4 = [a%4 for a in A]
x4 = A_4.count(0)
odd = A_2.count(1)
x2 = A_2.count(0)-x4
if x4-odd>=0:
    print('Yes')
elif x2==0 and x4-odd>=-1:
    print('Yes')
else:
    print('No')

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

numfour = 0
numtwo = 0

for i in a:
    if i % 4 == 0:
        numfour += 1
    elif i % 2 == 0:
        numtwo += 1

if (numfour*2+1) + (numtwo//2*2) >= N:
    print("Yes")
else:
    print("No")

Solution (Python):


"""
Created on 2019/3/23
Solved on 2019/3/
@author: shinjisu
"""




def getInt(): return int(input())

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


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m) for i in range(n)] 

def getIntMat(n, m):  
    
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    d.dmp((N), 'N')
    A = getIntList()
    d.dmp((A), 'A')
    odd, two, four = 0, 0, 0
    for e in A:
        if e % 4 == 0:
            four += 1
        elif e % 2 == 0:
            two += 1
        else:
            odd += 1
    d.dmp((odd, two, four), 'odd, two, four')
    if two > 0:
        odd += 1
    d.dmp((odd, four), 'odd, four')
    if four+1 >= odd:
        return 'Yes'
    else:
        return 'No'


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
count2 = len([0 for n in a if n % 2 == 0])
count4 = len([0 for n in a if n % 4 == 0])
count2 -= count4
print("Yes") if N - (2 * count4 + 1) <= 0 or N - (2 * count4) <= count2 else print("No")

Solution (Python):
n = int(input())
x2, x4, x = 0, 0, 0

for num in input().split(' '):
    tmp = int(num)
    x2 += tmp % 2 == 0 and tmp % 4 != 0
    x4 += tmp % 4 == 0
    x += tmp % 2 != 0

print("Yes" if x + (x2 != 0) <= x4 + 1 else "No")

Solution (Python):

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
cnt2=0
cnt4=0
for x in a:
    if x%4==0:
        cnt4+=1
    elif x%2==0:
        cnt2+=1
if cnt2!=0:
    if n-cnt2-cnt4+1<=cnt4+1:
        print("Yes")
    else:
        print("No")
else:
    if n-cnt2-cnt4<=cnt4+1:
        print("Yes")
    else:
        print("No")

Solution (Python):


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

nums = [0, 0, 0]

for tmp in a:
	if tmp%4 == 0:
		nums[0] += 1
	elif tmp%2 == 0:
		nums[1] += 1
	else:
		nums[2] += 1
		
if nums[1] > 0:
	pass
else:
	nums[2] -= 1

if nums[0] >= nums[2]:
	print('Yes')
else:
	print('No')

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

a2 = len(list(filter(lambda x:x%2==0, a)))
a4 = len(list(filter(lambda x:x%4==0, a)))

if n == a2:
    print("Yes")
    exit()

a2_ = a2 - a4
n = n if a2_==0 else (n-a2_+1)
if n//2 <= a4:
    print("Yes")
else:
    print("No")

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

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

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

ans = "No"
two_mul = []
four_mul = []
for i in a:
    if i % 2 == 0 and i % 4 != 0:
        two_mul.append(i)
    elif i % 4 == 0:
        four_mul.append(i)

if len(four_mul) == 0:
    if len(two_mul) == N:
        ans = "Yes"
else:
    if len(two_mul) == 0:
        if len(four_mul) >= N//2:
            ans = "Yes"
    else:
        if ((N - len(two_mul))+1)//2 <= len(four_mul):
            ans = "Yes"

print(ans)

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

c1 = 0
c2 = 0
c4 = 0
for x in a:
  if x%4==0:
    c4 += 1
  elif x%2==0:
    c2 += 1
  else:
    c1 += 1

if c1>0:
  p = 1
  c1 -= 1
elif c2>0:
  p = 2
  c2 -= 1
else:
  p = 4
  c4 -= 1

while c1+c2+c4>0:
  if p==1:
    if c4>0:
      c4 -= 1
      p = 4
    else:
      print "No"
      break
  elif p==2:
    if c2>0:
      c2 -= 1
      p = 2
    elif c4>0:
      c4 -= 1
      p = 4
    else:
      print "No"
      break
  else:
    if c1>0:
      c1 -= 1
      p = 1
    elif c2>0:
      c2 -= 1
      p = 2
    else:
      c4 -= 1
      p = 4
else:
  print "Yes"

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

count_odd = 0
count_4 = 0
count_2 = 0
for i in A:
    if i % 2 != 0:
        count_odd += 1
    else:
        if i % 4 == 0:
            count_4 += 1
        else:
            count_2 += 1
            
if count_4 + 1 >= count_odd + count_2:
    print('Yes')
else:
    if count_2 > 1 and count_4 + 1 - count_odd > 0:
        print('Yes')
    else:
        print('No')

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

tmp = [a%4 for a in A]
four = tmp.count(0)
two = tmp.count(2)

if(four+two//2 >= N//2):
  print("Yes")
else:
  print("No")

Solution (Python):



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

    for ai in a:
        if ai % 4 == 0:
            four_count += 1
        elif ai % 2 == 0:
            two_count += 1

    if four_count >= n // 2:
        print('Yes')
    else:
        need = n - 2 * four_count

        if two_count >= need:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N = int(input())
    x4 = 0
    x2 = 0
    for a in map(int, input().split()):
        if a % 4 == 0:
            x4 += 1
        elif a % 2 == 0:
            x2 += 1
    if x2 == 0 and x4*2 + 1 >= N:
        print("Yes")
    elif x4*2 + x2 >= N:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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


num4, num2 = 0, 0
for a in a:
    if a % 4 == 0: num4 += 1
    elif a % 2 == 0: num2 += 1

if num2 > 1:
    if num4 >= (N-(num2-1))//2: print( 'Yes' )
    else: print( 'No' )
else:
    if num4 >= N//2: print( 'Yes' )
    else: print( 'No' )

Solution (Python):

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






n = I()
a = LI()
d = [0,0]
for i in a:
    if i%2:
        d[0] += 1
    if i%4 == 0:
        d[1] += 1
if n % 2:
    d[0] -= 1
d[0] -= d[1]
if d[0] <= 0:
    print("Yes")
else:
    print("No")

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

cnt_t = 0
cnt_f = 0

for i in l:
  if i%4==0:
    cnt_f += 1
  elif i%2==0:
    cnt_t += 1

num = N-cnt_t-cnt_f

if cnt_t == 0:
  cnt_f += 1
if num <= cnt_f:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    _ = int(input())
    a = [int(s) for s in input().split()]
    if solve(a):
        print('Yes')
    else:
        print('No')

def solve(a):
    odds = 0
    f4 = 0

    for i in a:
        if i % 4 == 0:
            f4 += 1
        elif i % 2 != 0:
            odds += 1
    
    if f4 + odds == len(a) and f4 + 1 == odds:
        return True
    elif f4 >= odds:
        return True
    else:
        return False

main()

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

Solution (Python):
N=int(input())
a=list(map(int,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 cnt2==0:
    if cnt4>=N-cnt4-1:
        print('Yes')
    else:
        print('No')
else:
    if cnt4>=N-cnt4-cnt2:
        print('Yes')
    else:
        print('No')

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

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

if cnt >= n//2:
    print('Yes')
else:
    if n - cnt*2 <= two:
        print('Yes')
    else:
        print('No')

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

cnt = 0
cnt2 = 0
for i in range(N):
    if A[i] % 4 == 0:
        cnt += 1
    elif A[i] % 2 == 0:
        cnt2 += 1
    
ans = 'No'
if cnt2 % 2 == 0:
    if cnt >= (N - cnt2) // 2:
        ans = 'Yes'
else:
    if cnt >= (N - cnt2 + 1) // 2:
        ans = 'Yes'
        
print(ans)

Solution (Python):
input()
a = [int(i) for i in input().split()]
c = [i for i in a if i % 4 != 2]
if len(c) != len(a):
    c.append(1)
if len([i for i in c if i % 4 != 0]) - 1 <= len([i for i in c if i % 4 == 0]):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
one = list(filter(lambda x:x%2!=0,L))
two = list(filter(lambda x:x%4!=0 and x%2==0,L))
four = list(filter(lambda x:x%4==0,L))
if len(one) - len(four) == 1 :
    if len(two) >=1 :
        print("No")
    else:
        print("Yes")
elif len(one) <= len(four):
    print("Yes")
else:
    print("No")

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
a2 = [i % 2 for i in a].count(0)
a4 = [i % 4 for i in a].count(0)
a0 = n - a2
a2 -= a4
if a2 == 0:
    if a0 <= a4+1:
        ans = "Yes"
    else:
        ans = "No"
else:
    if a0 <= a4:
        ans = "Yes"
    else:
        ans = "No"
print(ans)

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