Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}.  A row in the airplane Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.

The first line contains two integers n and k (1 ≤ n ≤ 10000, 1 ≤ k ≤ 100) — the number of rows and the number of groups of soldiers, respectively. The second line contains k integers a1, a2, a3, ..., ak (1 ≤ ai ≤ 10000), where ai denotes the number of soldiers in the i-th group. It is guaranteed that a1 + a2 + ... + ak ≤ 8·n.

If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes). You can choose the case (lower or upper) for each letter arbitrary.

NoteIn the first sample, Daenerys can place the soldiers like in the figure below:  In the second sample, there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.In the third example Daenerys can place the first group on seats (1, 2, 7, 8), and the second group an all the remaining seats.In the fourth example she can place the first two groups on seats (1, 2) and (7, 8), the third group on seats (3), and the fourth group on seats (5, 6).

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)

int r[8];

void solve(bool x) {
    if(x) printf("YES\n");
    else printf("NO\n");
}

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    int mid = 0;
    while(k--) {
        int x; scanf("%d", &x);
        mid += x >> 2;
        r[x & 3]++;
    }

    r[1] += r[3];
    r[2] += r[3];
    if(mid >= n) {
        int need = 0;
        need += r[1] + r[2];
        need += (mid - n) * 2;
        solve(need <= n * 2);
    } else {
        mid = n - mid;
        int side = n * 2;
        int t = min(side, r[2]);
        side -= t;
        r[2] -= t;
        if(!r[2]) {
            solve(mid * 2 + side >= r[1]);
        } else {
            if(r[1] >= r[2]) solve(r[2] + (r[1] - r[2] +1) / 2 <= mid);
            else {
                mid -= r[1];
                solve(mid + mid / 2 >= r[2] - r[1]);
            }
        }
    }

    return 0;
}

#include <iostream>

using namespace std;
int n,k;
int have[3];
int main()
{
   cin >> n >> k;
    have[1]=n;
    have[2]=2*n;
    int x;
    int cnt;
    for (int i=0;i<k;i++)
    {
        cin >> x;
        while (x)
        {
            cnt = x;
            if (x >= 4 && have[1])
            {
                have[1]--;
                x-=4;
            }
            else if (x >= 2 )
            {
                if (have[2])
                {
                    x-=2;
                    have[2]--;
                }
                else if(have[1])
                {
                    have[1]--;
                    have[0]+=1;
                    x-=2;
                }
                else if(have[0])
                {
                    have[0]--;
                    x-=1;

                }
            }
            else if (x >= 1)
            {
                if (have[0] >= 1)
                    {
                    have[0]--;
                    x--;
                    }

                else if (have[1])
                {
                    have[1]--;
                    have[2]++;
                    x--;
                }
                  else if (have[2] )
                {
                    have[2]--;
                    x--;
                }
            }
            if (cnt == x)
            {
                return (cout << "NO" << endl,0);
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
int n,k,a[4000000];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++) scanf("%d",&a[i]);
    int ans1=n,ans2=2*n;
    for(int i=1;i<=k;i++){
        int d=min(ans1,a[i]/4);
        ans1-=d;a[i]-=d*4;
    }
    ans2+=ans1;
    for(int i=1;i<=k;i++){
        int d=min(ans2,a[i]/2);
        ans2-=d;a[i]-=d*2;
    }
    int tmp=ans2+ans1;
    for(int i=1;i<=k;i++) tmp-=a[i];
    if(tmp>=0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
int a[1005];
bool cmp(int a, int b)
{
    return a > b;
}
int main()
{
    ll n, k;
    cin >> n >> k;
    ll four = n, two = n*2;
    ll one = 0;
    bool ok = true;
    for(int i = 1; i <= k; i++)
    {
        cin >> a[i];
    }
    sort(a+1, a+1+k, cmp);
    for(int i = 1; i <= k; i++)
    {
        int cc = a[i];
        if(four != 0)
        {
            int ccm = cc;
            four -= (cc+1)/4;
            cc = cc%4;
            if(cc == 3)cc = 0;
            if(four < 0)
            {
                cc += -four*4;
                four = 0;
            }
//            cout << cc << endl;
            if(cc == 1 && (ccm+1)/4 != 0){k++;a[k] = 1;cc = 0;}
        }
        if(cc != 0)
        {
            two -= (cc+1)/2;
            cc = cc%2;
            if(two < 0)
            {
                if(four != 0)
                {
                    four--;
                    if(cc == 1)
                    {
                        if(one != 0){one--; four++;}
                        else two+=2;
                        cc = 0;
                    }
                    else
                    {
                        one++;
                        two++;
                        cc = 0;
                    }
                }
                else
                {
                    if(one != 0 && cc == 1){one--;cc = 0;}
                    else
                    {
                        if(one >= 2){one -= 2;cc = 0;}
                        else
                        {cc += -two*2;
                        two = 0;}
                    }
                }
            }
            else cc = 0;
        }
//        cout << cc << ' ' << two << ' ' << four << endl;
        if(cc > 0)ok = false;
    }
    if(ok)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/

#include<bits/stdc++.h>
//#define DEBUG
//#ifdef DEBUG
//code to debug
//#endif
//#undef DEBUG
using namespace std;

const int MOD=998244353,MAXN=105,LOGN=18,MAXM=1005;
#define DEBUG 0
#define F(i,p,n) for(int i=p;i<n;i++)
#define I(i,p,q) for(int i=p;i>=q;i--)
#define forall(itr,x)	for( __typeof((x).begin()) itr=(x).begin(); itr!=(x).end(); itr++)
#define Ss(x) scanf("%s",x)
//#define S(x) scanf("%d",&x)
#define Sl(x) scanf("%lld",&x)
//#define getcx getchar_unlocked
#define getcx getchar
inline void S(int& n)
{
    n=0; int ch = getcx(); int sign = 1;
    while(ch < '0' || ch > '9') { if(ch == '-') sign=-1; ch = getcx(); }
    while(ch >= '0' && ch <= '9') { n = (n << 3) + (n << 1) + ch - '0', ch = getcx(); }
    n = n * sign;
}
#define Ps(x) printf("%d  ",x)
#define P(x) printf("%lld\n",x)
typedef long long int LL;
#define modulo(x,y,z) (x+y)<0?x+y+z:((x+y>=z)?x+y-z:x+y)
#define Debug(x) cerr << #x << "=" << x << endl
#define Debugarr(x,n) cerr<<"array "<<#x<<":"<<endl; F(ij,0,n) cerr<<ij<<". "<<x[ij]<<endl; cerr<<endl
#define Debugarr2(x,m,n) cerr<<"array "<<#x<<":"<<endl; F(ij,0,m) {F(jk,0,n) cerr<<x[ij][jk]<<" "; cerr<<endl;} cerr<<endl
#define Debugset(x) cerr<<"Set "<<#x<<":"<<endl; forall(iittrr,x) cerr<<(*iittrr)<<endl; cerr<<endl
#define Debugmap(x) cerr<<"Map "<<#x<<":"<<endl; forall(iittrr,x) cerr<<"( "<<(iittrr->Fi)<<" , "<<(iittrr->Se)<<" )"<<endl; cerr<<endl
#define DebugObj(x) cerr<<"Object "#x<<" : "<<endl; x.print(); cerr<<endl
#define DebugObjArr(x,n) cerr<<"Object Array "<<#x<<" : "<<endl; F(pqr,0,n) { cerr<<pqr<<". "<<endl; x[pqr].print(); cerr<<endl; } cerr<<endl
#define DebugTime(a,b,str) cerr<<"time taken [ "<<str<< " ] : "<<double(b-a)/CLOCKS_PER_SEC<<endl
#define pii pair<int,int>
#define Fi first
#define Se second
#define chk(x,n) (x[n>>5]&(1<<(n&31))) //unsigned int
//#define set(x,n) (x[n>>5]|=(1<<(n&31)))//32 bit
const int SHIFT=30,ETF=MOD-1,LIM=(int)1e9+1;
#define WHITE 0
#define GREY 1
#define BLACK 2

const LL INF=(LL)1e18+1;

const double PI=(double)acos(-1),EPSILON=1e-10;

bool exhaust4Group(int bigseats, vector<int>& groupsCount) {
	int used4=min(bigseats,groupsCount[4]);
	bigseats-=used4;
	groupsCount[4]-=used4;
	int used3=min(bigseats,groupsCount[3]);
	bigseats-=used3;
	groupsCount[3]-=used3;
	int used21=min(bigseats,min(groupsCount[2],groupsCount[1]));
	bigseats-=used21;
	groupsCount[2]-=used21;
	groupsCount[1]-=used21;
	int used22=min(bigseats/2,(groupsCount[2])/3);
	bigseats-=2*used22;
	groupsCount[2]-=3*used22;
	int used2=min(bigseats,groupsCount[2]);
	bigseats-=used2;
	groupsCount[2]-=used2;
	int used1=min(bigseats,(groupsCount[1]+1)/2);
	bigseats-=used1;
	groupsCount[1]-=2*used1;
	if(groupsCount[1]<0) {
		groupsCount[1]=0;
	}
	// Debug(bigseats);
	// Debugarr(groupsCount,5);
	for (int i=1; i<=4; ++i) {
		if (groupsCount[i])
			return false;
	}
	return true;
}

bool exhaust2Group(int smallseats, vector<int>& groupsCount) {
	// Debug(smallseats);
	// Debugarr(groupsCount,5);
	return groupsCount[1]+groupsCount[2]<=smallseats;
}

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> groupsCount(5,0);
	for (int i=0; i<k; ++i) {
		int x;
		S(x);
		groupsCount[4]+=x/4;
		groupsCount[x%4]++;
	}
	if (exhaust4Group(n,groupsCount)) {
		printf("YES\n");
	} else {
		groupsCount[1]+=groupsCount[3];
		groupsCount[2]+=groupsCount[3];
		groupsCount[2]+=2*groupsCount[4];
		groupsCount[3]=groupsCount[4]=0;
		if (exhaust2Group(2*n,groupsCount)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a,b,c,p;
int s[4],n,k;
int main()
{
    scanf("%d%d",&n,&k);
    a=n<<1;b=n;
    for(int i=0;i<k;++i)
	{
	 	scanf("%d",&p);
        while(p>=3){
            if(b>0) p-=4,--b;
            else if(a>0) p-=2,--a;
            else{
                printf("NO");
                return 0;
            }
        }
        if(p>0) s[p]++;
    }
    while(s[2]){
        if(a>0) --s[2],--a;
        else if(b>0) --s[2],--b,++c;
        else --s[2],s[1]+=2;
    }
    if(s[1]<=c+a+2*b) printf("YES");
    else printf("NO");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);

	int n,k,twos,fours,tmp,i;
	int leftovers[4]={0};
	vector<int> armies;

	scanf("%d %d", &n, &k);
	fours = n;
	twos=n*2;
	for(int j=0; j<k; j++)
	{
		scanf("%d" , &tmp);
		armies.push_back(tmp);
	}

	for( i=0; i<k; i++)
	{
		if(fours*4>=armies[i])
		{
			fours-=(armies[i]/4);
			if(armies[i]%4 == 3)
				fours--;
			else
			{
				if(armies[i]%4==2 and twos>0)
				{
					twos--;
				}
				else
				{
					leftovers[armies[i]%4]++;
				}
			}
		}
		else
		{
			armies[i]-=fours*4;
			fours=0;
			break;
		}
	}

	for(; i<k; i++)
	{
		if(twos*2 >= armies[i])
		{
			twos-=(armies[i]/2);
			leftovers[armies[i]%2]++;
		}
		else
		{
			armies[i]-=(twos*2);
			twos=0;
			leftovers[armies[i]%2]++;
			break;
		}
	}

	while(fours--)
	{
		if(leftovers[1] && leftovers[2])
		{
			leftovers[1]--;
			leftovers[2]--;
		}
		else if(leftovers[1])
		{
			leftovers[1]-=2;
		}
		else if(leftovers[2])
		{
			if(fours)
			{
				leftovers[2]-=3;
				fours--;
			}
			else
			{
				leftovers[2]--;
			}
		}
	}

	int sum=0;
	sum += (leftovers[1]>0)?leftovers[1] : 0;
	sum += (leftovers[2]>0)?leftovers[2] : 0;

	if(twos<sum)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline long long read(){
   long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e6 + 10;
int a[maxn];
int main(){
    int n = read(),k = read();
    int cnt4 = n ,cnt2 = n * 2,cnt1 = 0;
    for(int i=1; i<=k; i++){
        a[i] = read();
        int d = min(a[i] / 4,cnt4);
        cnt4 -= d;
        a[i] -= d * 4;
    }
    cnt2 += cnt4;
    for(int i=1; i<=k; i++){
        int d = min(a[i] / 2, cnt2);
        cnt2 -= d;
        a[i] -= d * 2;
    }
    cnt1 = cnt4 + cnt2;
    for(int i=1; i<=k; i++){
        cnt1 -= a[i];
    }
    if (cnt1 < 0) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;
const int maxn=  1e5+10;
int a[maxn];
bool cmp(int a1,int b1)
{
    return a1>b1;
}
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<k;i++)
        scanf("%d",&a[i]);
    int c1=n,c2=n*2,c3=0,flag=0;
    sort(a,a+k,cmp);
    //如果有4的话就先填中间的，如果3的话也填中间的，
    //如果是2的话，先填两边的，如果两边填完了就填中间的余下1
    //如果是1的话，先填中间的，如果中间的满了，就填两边的。
    for(int i=0;i<k;i++)
    {
        while(a[i]>=4&&c1)
        {
            c1--;
            a[i]-=4;
        }
        while(a[i]>=3&&c1)
        {
            c1--;
            a[i]-=3;
        }
        while(a[i]>=2&&c2)
        {
            c2--;
            a[i]-=2;
        }
        while(a[i]>=2&&c1)
        {
            c1--;
            c3++;
            a[i]-=2;
        }
        while(a[i]>=1&&c3)
        {
            c3--;
            a[i]-=1;
        }
        while(a[i]>=1&&c1)
        {
            c1--;c2++;
            a[i]-=1;
        }
        while(a[i]>=1&&c2)
        {
            c2--;
            a[i]-=1;
        }
        if(a[i]>0) {
            printf("NO\n");
            flag=1;
            break;
        }
    }
    if(!flag) printf("YES\n");
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int Maxn=110;
int A[Maxn];
int main()
{
  int N,K; scanf("%d%d",&N,&K);
  for(int i=1;i<=K;i++) scanf("%d",&A[i]); int last=8*N; int last4=N,last2=2*N;
  for(int i=1;i<=K;i++)
  {
    int ned=min(A[i]/4,last4);
    last4-=ned; A[i]-=ned*4;
    if(last4==0) break;
  }
  for(int i=1;i<=K;i++)
  {
    int ned=min(A[i]/2,last2);
    last2-=ned; A[i]-=ned*2;
    if(last2==0) break;
  }
  int s1=0; int s2=0; int s3=0;
  for(int i=1;i<=K;i++)
  {
    if(A[i]>3){printf("NO\n"); return 0;}
    else if(A[i]==1) s1++;
    else if(A[i]==2) s2++;
    else if(A[i]==3) s3++;
  }
  while(last4)
  {
    if(!s1 && !s2 && !s3) break;

    if(s3>3)
    {
      int ned=min(last4/3,s3/4);
      s3-=ned*4; last4-=ned*3;
      continue;
    }

    if(s3)
    {
      int ned=min(last4,s3);
      s3-=ned; last4-=ned;
      continue;
    }

    if(s2 && s1)
    {
      int ned=min(last4,min(s1,s2));
      s1-=ned; s2-=ned; last4-=ned;
      continue;
    }

    if(s1>1)
    {
      int ned=min(last4,s1/2);
      s1-=2*ned; last4-=ned;
      continue;
    }

    if(s2>2)
    {
      int ned=min(last4/2,s2/3);
      last4-=ned*2; s2-=ned*3;
      continue;
    }

    if(s2)
    {
      int ned=min(last4,s2);
      s2-=ned; last4-=ned;
      continue;
    }

    if(s1)
    {
      int ned=min(last4,s1);
      s1-=ned; last4-=ned;
      continue;
    }
  }

  while(last2)
  {
    if(!s1) break;

    if(s1)
    {
      int ned=min(last2,s1);
      s1-=ned; last2-=ned;
      continue;
    }
  }

  if(s1 || s2 || s3) printf("NO\n");
  else printf("YES\n");
  return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <fstream>
#include <map>
#include <set>
#include <queue>
#include <memory.h>

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PI;
typedef vector<PI> VPI;

#define FOR(i,a,n) for (int i = (a); i < (n); ++i)
#define FORE(i,a,n) for (int i = (a); i <= (n); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FORE(i,0,n)
#define LL long long
#define FIR(n) REP(i,n)
#define FJR(n) REP(j,n)
#define ALL(v) v.begin(), v.end()

#define FI FIR(n)
#define FJ FJR(n)
#define FR(i,a) FOR(i,a,n)
#define REPN(i) REP(i,n)

#define GI(n) scanf("%d", &n)
#define GI2(n,m) scanf("%d %d", &n, &m)

int main() {
#ifdef LOCALF
	freopen("input.txt", "rt", stdin);
#endif

	int n, k;
	GI2(n, k);

	bool ok = true;
	int a;

	VI v;
	int t4 = n;
	FIR(k){
		GI(a);
		int x4 = min(t4, a / 4);
		t4 -= x4;
		a -= 4 * x4;

		if (a)
			v.push_back(a);

	}

	if (t4 == 0) {
		int t2 = 2 * n;
		for (int rem : v)
			t2 -= (rem + 1) / 2;

		puts(t2 >= 0 ? "YES" : "NO");
	}
	else {
		sort(ALL(v));
		while (t4 && v.size() && v.back() == 3) {
			--t4;
			v.pop_back();
		}

		while (t4 && v.size() >= 2 && v[0] == 1 && v.back() == 2) {
			v.pop_back();
			v.erase(v.begin());
			--t4;
		}

		while (t4 && v.size() >= 2 && v[0] == 1 && v[1] == 1) {
			v.erase(v.begin());
			v.erase(v.begin());
			--t4;
		}

		int ones = 0;
		while (t4 && v.size()) {
			--t4;
			v.pop_back();
			++ones;
		}

		int t2 = 2 * n;
		bool ok = true;
		for (int rem : v) {
			int x2 = min(t2, rem / 2);
			t2 -= x2;
			rem -= 2 * x2;

			if (t2 && rem) {
				--rem;
				--t2;
			}
			if (rem > ones)
				ok = false;
			else
				ones -= rem;
		}

		puts(ok ? "YES" : "NO");
	}

}

#define _CRT_SECURE_NO_WARNINGS
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;

int n, k, seat4 = 0, seat2 = 0, seat1 = 0;
int p[105];
int rp[4] = {0};
int main() {
	scanf("%d %d",&n,&k);
	seat4 = n;
	seat2 = n * 2;
	for (int i = 0; i < k; i++) {
		scanf("%d",&p[i]);
		if (seat4 > 0) {
			int temp = min(seat4, p[i] / 4);
			seat4 -= temp;
			p[i] -= temp*4;
			if(p[i]<4)
				rp[p[i] % 4]++;
			else
			{
				seat2 -= p[i] / 2;
				p[i] %= 2;
				rp[p[i] % 2]++;
			}
		}
		else {
			seat2 -= p[i] / 2;
			p[i] %= 2;
			rp[p[i] % 2]++;
		}
	}
	if (seat2 < 0) {
		printf("NO\n");
		return 0;
	}

	if (seat4 >= rp[3]) {
		seat4 -= rp[3];
		rp[3] = 0;
	}
	else {
		rp[3] -= seat4;
		seat4 = 0;
	}

	int temp = min(rp[1], rp[2]);
	if (seat4 >= temp) {
		seat4 -= temp;
		rp[1] -= temp;
		rp[2] -= temp;
	}
	else {
		rp[1] -= seat4;
		rp[2] -= seat4;
		seat4 = 0;
	}

	seat2 += seat4;
	seat1 += seat4;

	if (seat1 >= rp[1]) {
		seat1 -= rp[1];
		rp[1] = 0;
	}
	else {
		rp[1] -= seat1;
		seat1 = 0;
	}

	if (seat1 >= rp[3]) {
		seat1 -= rp[3];
		rp[2] += rp[3];
		rp[3] = 0;
	}
	else {
		rp[3] -= seat1;
		rp[2] += seat1;
		seat1 = 0;
	}

	if (seat2 + seat1 / 2 >= rp[1] + rp[2] + rp[3] * 2)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN=10005;
int a[MAXN];
int main(){
  	int n,k,p;
  	memset(a,0,sizeof(a));
  	scanf("%d%d",&n,&k);
  	int leftfour=n,lefttwo=n*2,leftone=0;
  	for(int i=0;i<k;i++){
  		scanf("%d",&p);
  		a[p]++;
  	}
  	for(int i=10000;i>0;i--){
  		while(a[i]--){
  			if(leftfour){
  				leftfour--;
  				int tt=min(4,i);
  				if(i-tt>0)
  					a[i-tt]++;
  				if(tt==1)
  					lefttwo++;
  				if(tt==2)
  					leftone++;
  			}
  			else if(lefttwo){
  				lefttwo--;
  				int tt=min(2,i);
  				if(i-tt>0)
  					a[i-tt]++;
  			}
  			else if(leftone){
  				leftone--;
  				int tt=1;
  				a[i-tt]++;
  			}
  			else{
  				printf("NO\n");
  				return 0;
  			}
  		}
  	}
  	printf("YES\n");
  	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 100003

int main(void)
{
  int n,k;
  cin>>n>>k;

  int grp[k+1];

  for(int i=1;i<=k;i++)
  	cin>>grp[i];

  int two = n * 2, four = n , h2 = 0 , h1 = 0;

  for(int i=1;i<=k;i++){
  	if(grp[i]>3){
  		int need = grp[i] / 4;
  		int used = min(need , four);
  		grp[i] -= used * 4;
  		four -= used;
  	}
  	if(grp[i]>1){
  		int need = grp[i] / 2;
  		int used = min(need , two);
  		grp[i] -= (2*used);
  		two -= used;
  	}
  }

  for(int i=1;i<=k;i++){
    if(grp[i] == 2) {
  		if(h1){
  			h1--;
  			grp[i]-=2;
  		} else if (four) {

  			int one = 0;
  			for(int j=i+1;j<=k;j++)
  				if(grp[j] == 1) {
  					one=1;
  					grp[j] -= 1;
  					four--;
  					break;
  				}
  			if(!one){
  				if(four > 1){
  					four-=2;
  					h1+=2;
  				} else {
  					four-=1;
  					h2++;
  				}
  			}
  			grp[i]-=2;
  		}
  	} else if(grp[i] == 1){
  		if(h2) {
  			h2--;
  			grp[i]-=1;
  		}else if(two){
  			two--;
  			grp[i]-=1;
  		} else if(four){
  			four--;
  			h1++;
  			grp[i]-=1;
  		} else if(h1){
  			h1--;
  			grp[i]-=1;
  		}
  	} else if(grp[i] == 3){
  		if(four){
  			four--;
  			grp[i]-=3;
  		}
  	}
  	if(grp[i]>0){
  		cout<<"NO";
  		return 0;
  	}
  }
  cout<<"YES";
  return 0;
}

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
const int MAX_N = 1e04+10;
int x[MAX_N];
priority_queue<int> Qj, Qo;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++){
        scanf("%d",&x[i]);
    }
    int four = n;
    int two = 2*n;
    int one = 0;
    int num_one = 0;
    int num_two = 0;
    int num_three = 0;
    int num_four = 0;
    for(int i=1;i<=k;i++){
        if(x[i]==1) num_one++;
        else{
            if(x[i]%2==0){
                num_four += x[i]/4;
                if(x[i]%4==2)
                    num_two++;
            }
            else{
                if(x[i]%4==3){
                    num_three++;
                    num_four += x[i]/4;
                }
                if(x[i]%4==1){
                    num_one++;
                    num_four += x[i]/4;
                }
            }
        }
    }
    if(four>=num_four){
        four -= num_four;
        num_four = 0;
    }
    else{
        num_four -= four;
        num_two += num_four*2;
        four = 0;
    }
    if(four>=num_three){
        four -= num_three;
        num_three = 0;
    }
    else{
        num_three -= four;
        num_two+=num_three;
        num_one+=num_three;
        four = 0;
    }
    if(four>0){
        two += four;
        one += four;
        four = 0;
    }
    if(two >= num_two){
        two -=num_two;
    }
    else{
        num_two-=two;
        two = 0;
        num_one += num_two * 2 ;
    }
    if(two>0)
        one += two;
    if(one >= num_one) printf("YES\n");
    else printf("No\n");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,k;
int s4,s2,s1,n2,n1;
int main()
{
	scanf("%d%d",&n,&k);
	s4=n;
	s2=n*2;
	for(int i=1;i<=k;i++)
	{
		int x;
		scanf("%d",&x);
		while(s4&&x>=4)
		{x-=4;s4--;}
		n2+=x/2;
		n1+=x%2;
	}
	s2+=s4;
	s1+=s4;
	if(s1<n1)
	{
		s2-=n1-s1;
		s1=0;
	}
	else s1-=n1;
	s2+=s1/2;
	if(s2<n2)printf("NO");
	else printf("YES");
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>

using namespace std;

#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define ll long long

double eps = 1e-7;
const long long INF = 1e9;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, k;
	cin >> n >> k;

	vector<int> a(k);
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}

	int cur = 0;
	int cnt = 0;

	int cc = n;
	int l = n;
	int r = n;

	for (int j = 0; j < k && cc > 0; j++) {
		if (a[j] >= 4) {
			a[j] -= 4;
			cc--;
			j--;
		}
	}

	for (int j = 0; j < k && cc > 0; j++) {
		if (a[j] >= 3) {
			a[j] -= 3;
			cc--;
			j--;
		}
	}

	for (int i = 0; i < k && cc > 0; i++) {
		if (a[i] >= 2) {
			for (int j = 0; j < k; j++) {
				if (a[j] == 1 && i != j){
					a[i] -= 2;
					a[j] -= 1;
					cc--;
					i--;
					break;
				}
			}
		}
	}

	for (int i = 0; i < k && cc > 0; i++) {
		if (a[i] >= 2) {
			for (int j = 0; j < k; j++) {
				if (a[j] >= 1 && i != j) {
					a[i] -= 2;
					a[j] -= 1;
					cc--;
					i--;
					break;
				}
			}
		}
	}

	//for (int i = 0; i < k; i++) {
	//	cout << a[i] << " ";
	//}

	for (int i = 0; i < k && cc > 0; i++) {
		if (a[i] >= 1) {
			for (int j = 0; j < k; j++) {
				if (a[j] >= 1 && i != j) {
					a[i]--;
					a[j]--;
					cc--;
					i--;
					break;
				}
			}
		}
	}

	for (int i = 0; i < k && l > 0; i++) {
		if (a[i] >= 2) {
			a[i] -= 2;
			l--;
			i--;
		}
	}

	for (int i = 0; i < k && r > 0; i++) {
		if (a[i] >= 2) {
			a[i] -= 2;
			r--;
			i--;
		}
	}
	for (int i = 0; i < k && l > 0; i++) {
		if (a[i] >= 1) {
			a[i]--;
			l--;
			i--;
		}
	}

	for (int i = 0; i < k && r > 0; i++) {
		if (a[i] >= 1) {
			a[i]--;
			r--;
			i--;
		}
	}

	bool flag = true;
	for (int j = 0; j < k; j++) {
		if (a[j] != 0) {
			flag = false;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,k,a[N],count=0,four,sum=0,odd=0,two,total;
		cin>>n>>k;
		rep(i,0,k)
		{
			cin>>a[i];
			sum+=a[i];
			count+=a[i]/4;
			if(a[i]&1)
				odd++;
		}
		if(sum+odd>8*n){
			cout<<"NO"<<endl;
			return 0;
		}
		four=n-odd;
		two=2*n+odd;
		total=sum;

		//cout<<count<<(total-four*4)/2<<(2*n+n-four)<<endl;
		if(count<four && (total-count*4)>(4*n+(n-count)*2+(n-count)))
			cout<<"NO";
		else
			cout<<"YES";
	}
	return 0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstring>
#include<iostream>
#include<sstream>
#include<cmath>
#include<vector>
#define LL long long
#define INF 0x3f3f3f3f
#define eps 1e-6
#include<deque>
using namespace std;
const int maxn = 200000+50;
int n,k;
int a[105];
int main()
{
    while(~scanf("%d%d",&n,&k)){
        for(int i = 0;i<k;i++){
            scanf("%d",&a[i]);
        }
        int sum1 = n;
        int sum2 = 2*n;
        for(int i = 0;i<k;i++){
            int d = min(sum1,a[i]/4);
            sum1 -= d;
            a[i] -= d*4;
        }
        sum2+=sum1;
        for(int i = 0;i<k;i++){
            int d = min(sum2,a[i]/2);
            sum2 -= d;
            a[i] -= d*2;
          //  cout<<a[i]<<endl;
        }
        int tmp  = sum2+sum1;
        for(int i = 0;i<k;i++){
            //    cout<<a[i]<<endl;
            tmp -= a[i];
        }
        if(tmp>=0){
            puts("YES");
        }
        else
            puts("NO");
    }
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int shuzu = 100+10 ;
#define MAXN 0x3f3f3f3f;
int a[shuzu];
int main()
{
    int row,team;
    while(cin>>row>>team)
    {
        memset(a,0,sizeof(a));
        int si=row,er=row*2;
        for(int i=1;i<=team;i++)
        {
            scanf("%d",&a[i]);
            int minn = min(si,a[i]/4);
            a[i] -= 4*minn;
            si -= minn;
        }
        er+=si;
        for(int i=1;i<=team;i++)
        {
            int minn = min(er,a[i]/2);
            a[i] -= 2*minn;
            er -= minn;
        }
        int dan = er + si;
        for(int i=1;i<=team;i++)
        {
            if(a[i]>0)
                dan -= a[i];
        }
        if(dan>=0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int MAXN = 1e4+7;
const int inf = 1e9;
int n,k;
int num[MAXN];

int main()
{
    scanf("%d%d",&n,&k);
    //x1表示４连座，x2表示２连座，x3表示４连座已经坐了两个了（还能坐１个的）
    int x1 = n,x2 = n*2,x3 = 0;
    int x;
    for(int i = 0; i < k; ++i)scanf("%d",&num[i]);
    sort(num,num+k);
    for(int i = k-1; i >= 0; --i)
    {
        x = num[i];
        if(x1)//如果还有４个座位的
        {
            int d = x/4;//先坐４个座位的
            if(x1 >= d)//如果都能坐上去
            {
                x1 -= d;//坐上去
                if(x % 4 == 3)//剩下３个
                {
                    if(x3>=3)x3-=3;
                    else if(x3&&x2)x3--,x2--;
                    else if(x1)x1--;
                    else x2-=2;
                }
                else if(x%4 == 2)//剩下２个
                {
                    if(x2)x2--;
                    else if(x1)x1--,x3++;
                    else x3-=2;
                }
                else if(x%4==1)//剩下１个
                {
                    if(x3)x3--;
                    else if(x1)x1--,x2++;
                    else x2--;
                }
            }
            else//如果不能全部坐上去
            {
                x -= x1*4;//那么就先坐上１部分
                x1 = 0;
                int d2 = x/2;
                if(x2 >= d2)//２连座全部能坐上
                {
                    x2 -= d2;
                    if(x%2)//如果还有剩余
                    {
                        if(x3)x3--;
                        else x2--;
                    }
                }
                else//如果２连座不能全坐上
                {
                    x -= x2*2;//坐一部分
                    x2 = 0;
                    x3 -= x;
                }
            }
        }
        else //没有４个座位的了
        {
            int d2 = x/2;
            if(x2 >= d2)//２连座全部能坐上
            {
                x2 -= d2;
                if(x%2)//如果还有剩余
                {
                    if(x3)x3--;
                    else x2--;
                }
            }
            else//如果２连座不能全坐上
            {
                x -= x2*2;//坐一部分
                x2 = 0;
                x3 -= x;
            }
        }
        if(x1 <0 || x2<0 || x3 < 0) return 0*puts("NO");
    }
    puts("YES");
    return 0;
}

#include <iostream>
#include <vector>

using namespace std;

bool combPossible(int n, int k, vector<int> group){
    int total4seaters=n;
    int total2seaters=n*2;
    int singleSoilders=0;
    int fourSeatCount=0;
    for(int i=0;i<k;i++){
            while(group[i]>=4){
                total4seaters--;
                group[i]-=4;
            }
            if(group[i]==3){
                total4seaters--;
            }
            if(group[i]==2){
                total2seaters--;
            }
            if(group[i]==1){
                singleSoilders++;
            }
    }

    while(total2seaters>0 && total4seaters<0){
            total2seaters-=2;
            total4seaters++;
    }

    while(total4seaters>0 && total2seaters<0){
            total2seaters++;
            total4seaters--;
            if(singleSoilders>0)
                singleSoilders--;
            else{
                fourSeatCount++;
                if(fourSeatCount%2==0)
                    total2seaters++;
            }
    }

    while(singleSoilders>0 && (total2seaters>0 || total4seaters>0)){
        while(total2seaters>0){
            total2seaters--;
            singleSoilders--;

        }
        while(total4seaters>0){
            total4seaters--;
            singleSoilders-=2;

        }

    }

    if(total4seaters<0 || total2seaters<0 || singleSoilders>0)
        return false;

    else return true;
}

int main(){
    int n,k,solInGrp;;
    vector<int> group;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>solInGrp;
        group.push_back(solInGrp);
    }
    if(combPossible(n,k,group))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define endl "\n"

int32_t main(){
	int n, k;
	cin >> n >> k;

	int num_2_seats = 2*n;
	int num_4_seats = n;
	int num_1_seats = 0;

	// cout << num_4_seats << " " << num_2_seats << endl;

	vector<int> arr(k);
	for(int i = 0 ; i < k ; i++){
		cin >> arr[i];

	}
	sort(arr.begin(), arr.end(), greater<int>());
	bool poss = true;
	for(int i = 0 ; i < k; i++){
		if(num_2_seats == 0 && num_4_seats == 0 && num_1_seats==0){
			poss = false;
			break;
		}
		if(arr[i] >= 4){
			if(num_4_seats*4 >= arr[i]){
				int x = arr[i]/4;
				num_4_seats -= x;
				x=x*4;
				arr[i] -= x;
			}

			else{
				arr[i] -= num_4_seats*4;
				num_4_seats = 0;
				if(num_2_seats*2 >= arr[i]){
					int x = arr[i]/2;
					num_2_seats -= x;
					x = x*2;
					arr[i] -= x;
				}
				else{
					arr[i] -= num_2_seats*2;
					num_2_seats = 0;
				}
			}
		}
		if(arr[i] == 3){
			if(num_4_seats>=1){
				num_4_seats--;
				arr[i] = 0;
			}
			else if(num_2_seats >= 2){
				num_2_seats-=2;
				arr[i] = 0;
			}
			else{
				// cout << "HERE 1";
				poss = false;
			}
		}
		if(arr[i] == 2){
			if(num_2_seats >= 1){
				num_2_seats--;
				// cout << num_2_seats << " ";
				arr[i] = 0;
			}
			else if(num_4_seats>=1){
				// cout << num_4_seats << " ";
				num_4_seats--;
				num_1_seats++;
				arr[i] = 0;
			}
			else if(num_1_seats >=2){
				num_1_seats-=2;
				arr[i] = 0;
			}
			else{
				// cout << "HERE 2";
				poss = false;
			}
		}
		if(arr[i] == 1){
			if(num_1_seats >=1){
				num_1_seats--;
				arr[i] = 0;
			}
			else if(num_4_seats>=1){
				num_4_seats--;
				num_2_seats++;
				arr[i] = 0;
			}
			else if(num_2_seats >= 1){
				num_2_seats--;
				arr[i] = 0;
			}
			else{
				// cout << "HERE 3";
				poss=false;
			}
		}
	}
	if(!poss)
		cout << "NO\n";
	else
		cout << "YES\n";

}

#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back

using namespace std;

int arr[10000];

main()
{

    int n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int p;
        cin>>arr[i];
    }
    int m = n;
    for(int i=0;i<k;i++){
        int val = arr[i]/4;
        if(val<=m){
            m-=val;
            val=0;
        }
        else{
            val-=m;
            m=0;
        }
        arr[i] = arr[i]%4+(val*4);
    }
    for(int i=0;i<k;i++){
        if(arr[i]==3 && m){
            m--;
            arr[i]=0;
        }
    }
    int rem1 = m;
    n = 2*n+m;

    for(int i=0;i<k;i++){
        int val = arr[i]/2;
        if(val<=n){
            n-=val;
            val=0;
        }
        else{
            val-=n;
            n=0;
        }
        arr[i] = arr[i]%2+(val*2);
    }
    n+=rem1;
    int cnt=0;
    for(int i=0;i<k;i++){
        cnt+=arr[i];
    }
    if(cnt<=n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

#include <cstdio>
#include <cassert>

using namespace std;

class airplane_rows
{
    size_t unseated[ 3 ], two_seats, four_seats, two_seats_for_one;

    bool seat_3( size_t &u3 )
    {
        if ( u3 > 0 && four_seats > 0 )
        {
            if ( u3 <= four_seats )
                four_seats -= u3, u3 = 0;
            else
                u3 -= four_seats, four_seats = 0;
        }

        if ( u3 > 0 && two_seats > 0 )
        {
            if ( u3 <= two_seats )
                two_seats -=  u3, two_seats_for_one += u3, u3 = 0;
            else
                u3  -= two_seats, unseated[ 0 ] += two_seats, two_seats = 0;
        }

        if ( u3 > 0 && two_seats_for_one > 0 )
        {
            if ( u3  <= two_seats_for_one )
                two_seats_for_one -= u3, unseated[ 1 ] += u3, u3 = 0;
            else
                u3 -= two_seats_for_one, unseated[ 1 ] += two_seats_for_one, two_seats_for_one = 0;
        }

        return u3 == 0;
    }

    bool seat_2( size_t &u2 )
    {
        if ( u2  > 0 && four_seats > 0 )
        {
            if ( u2 <= four_seats )
                four_seats -= u2, two_seats_for_one += u2, u2 = 0;
            else
                u2 -= four_seats, two_seats_for_one += four_seats, four_seats = 0;
        }

        if ( u2 > 0 && two_seats > 0 )
        {
            if ( u2  <= two_seats )
                two_seats -=  u2, u2 = 0;
            else
                u2 -= two_seats, two_seats = 0;
        }

        if ( u2  > 0 && two_seats_for_one > 0 )
        {
            if ( u2 <= two_seats_for_one )
                two_seats_for_one -=  u2, unseated[ 0 ] += u2, u2 = 0;
            else
                u2 -= two_seats_for_one, unseated[ 0 ] += two_seats_for_one, two_seats_for_one = 0;
        }

        return u2 == 0;
    }

    bool seat_1( size_t &u1 )
    {
        if ( u1 > 0 && four_seats > 0 )
        {
            size_t seated_ones = 2 * four_seats;

            if ( u1  <= seated_ones )
                four_seats -= seated_ones / 2, four_seats -= seated_ones % 2, u1 = 0;
            else
                u1 -= seated_ones, four_seats = 0;
        }

        if ( u1 > 0 && two_seats > 0 )
        {
            if ( u1 <= two_seats )
                two_seats -=  u1, u1 = 0;
            else
                u1 -= two_seats, two_seats = 0;
        }

        if ( u1 > 0 && two_seats_for_one > 0 )
        {
            if ( u1  <= two_seats_for_one )
                two_seats_for_one -= u1, u1 = 0;
            else
                u1 -= two_seats_for_one, two_seats_for_one = 0;
        }

        return u1 == 0;
    }

    void read_group()
    {
        size_t a; scanf( "%u", &a );

        while( a >= 4 && four_seats > 0 )
            a -= 4, four_seats--;

        while( a >= 2 && two_seats > 0 )
            a -= 2, two_seats--;

        if ( a > 0 )
            unseated[ a - 1 ]++;
    }

public:

    airplane_rows() : two_seats( 0 ), four_seats( 0 ), two_seats_for_one( 0 )
    {
        size_t k, n; scanf( "%u %u", &n, &k ), four_seats = n, two_seats = 2 * n;

        unseated[ 0 ] = unseated[ 1 ] = unseated[ 2 ] = 0;

        for( size_t i = 0; i < k; i++ )
            read_group();

        if ( seat_3( unseated[ 2 ] ) &&
             seat_2( unseated[ 1 ] ) &&
             seat_1( unseated[ 0 ] ) )
            printf( "YES" );
        else
            printf( "NO" );
    }

};

int main()
{
    airplane_rows problem;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
const int   oo = 1e9 + 1;
const int  mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int n, k, a[maxn], have[5], i, cnt[3];
bool res = true;

void Init()
{
    cin >> n >> k;
    for (i = 1; i <= k; ++i) cin >> a[i];
    have[2] = 2 * n; have[4] = n;

    for (i = 1; i <= k; ++i)
    {
        while (a[i] >= 3)
        {
            if (have[4] == 0 && have[2] == 0)
            {
                cout << "NO"; return;
            }
            if (have[4] > 0) have[4]--, a[i] -= 4;
            else have[2]--, a[i] -= 2;
        }
        cnt[a[i]]++;
    }
    int k = min (have[2], cnt[2]); have[2] -= k; cnt[2] -= k;
        k = min (have[4], cnt[2]); have[4] -= k; cnt[2] -= k; have[1] += k;
    if (cnt[2] > 0) cnt[1] += 2 * cnt[2];
    if (have[1] + have[4] * 2 + have[2] >= cnt[1]) cout << "YES";
    else cout << "NO";
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("Div428B.inp", "r", stdin);
    //freopen(".out", "w", stdout);

	Init();
}
//Date 10 Month 7 Year 2017

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int maxn = 10000 + 5;
int a[maxn];

int main()
{
    int n, k;
    while (scanf("%d %d", &n, &k) != EOF)
    {
        int y = 0;
        for (int i = 1; i <= k; i++)
            {
                scanf("%d", &a[i]);
                y+=a[i];
            }
//printf("y=%d\n", y);
        sort(a + 1, a + k + 1);

        bool ok = true;
        int alone = 0;
        for (int i = 1 ; i <= k; i++)
        {
            if (a[i] & 1)
                {
                    alone++;
                    a[i] --;
                }
        }
//printf("alone=%d\n", alone);
        int rest = 0;

        if (alone > 4 * n)
        {
            puts("NO");
            continue;
        }
        else if (alone < n)
        {
            int four = n - alone;

            int x = 0;
            for (int i = k; i >= 1; i--)
            {
                if (x >= four)
                    break;
                while (a[i] >= 4 && x < four)
                {
                    a[i] -= 4;
                    x++;
                }
            }
            //printf("x=%d alone=%d\n", x, alone);
            rest += 2 * alone;
            rest += 2 * (n - alone - x);
            rest += (n - alone - x) ;
            rest += 2 * n * 2;
        }
        else if (alone == 2 * n)
        {
            rest += 2 * n * 2;
        }
        else if (alone <= 3 * n)
        {
            rest += (3 * n - alone) * 2;
            rest += n * 2;
        }
        else if (alone <= 4 * n)
        {
            rest += (4 * n - alone) * 2;
        }

        int sum = 0;
        for (int i = 1; i <= k; i++)
            sum += a[i];
//printf("rest =%d sum=%d\n", rest, sum);
        if (rest >= sum)
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define LL long long
#define INF (1<<30)
using namespace std;

int g[100100],sum;
int main(){
	int n,k;cin>>n>>k;
	int a=n*2,b=n;
	for(int i=1;i<=k;i++)
		scanf("%d",&g[i]),sum+=g[i];
	if(sum>n*8){printf("NO");return 0;}
	for(int i=1;i<=k;i++)
		while(g[i]>2&&b)g[i]-=4,b--;
	for(int i=1;i<=k;i++)
		while(g[i]>1&&a)g[i]-=2,a--;
	int c=b+a;
	for(int i=1;i<=k;i++)
		while(g[i]==2&&c)g[i]-=2,c--;
	int d=b+c;
	for(int i=1;i<=k;i++)
		while(g[i]>0)g[i]--,d--;
	if(d<0)printf("NO");
	else printf("YES");
}

#include <iostream>

using namespace std;

int twoLeft, fourLeft, halfFour;
int cnt[5];

int main()
{
	int n, k;
	bool ans = true;
	cin>>n>>k;
	twoLeft = (2*n);
	fourLeft = n;
	halfFour = 0;
	for (int i=0; i<k; i++)
	{
		int cur;
		cin>>cur;
		while (cur>=3)
		{
			if (fourLeft>0)
			{
				fourLeft--;
				cur-=4;
			}
			else if (twoLeft>1)
			{
				twoLeft-=2;
				cur-=4;
			}
			else
			{
				ans = false;
				break;
			}
		}
		cnt[cur]++;
	}
	while (cnt[2]>0)
	{
		if (twoLeft>0)
		{
			twoLeft--;
			cnt[2]--;
		}
		else if (fourLeft>0)
		{
			fourLeft--;
			halfFour++;
			cnt[2]--;
		}
		else
		{
			cnt[2]--;
			cnt[1]+=2;
		}
	}
	int total = (fourLeft*2) + twoLeft + halfFour;
	if (cnt[1] > total)
		ans = false;
	if (ans)
		cout<<"YES";
	else
		cout<<"NO";
}

#include<iostream>
using namespace std;
int k,n,t,a,b,c;
long long d,sum,daum;
int main(){
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>t;
        a+=t/4;b+=(t%4)/2;c+=(t&1);
    }
    b+=(a>n)*(a-n)*2;a=min(a,n);c+=2*(a+b>3*n)*(a+b-3*n);b=min(b,3*n-a);
    //cout<<a<<' '<<b<<' '<<c<<endl;
    if(a<=n&&b<=3*n-a&&a*4+b*2+c*2<=n*8){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

int main(){
    ios;
    ll n,k;
    cin>>n>>k;

    ll a[k+3];
    F(i,1,k) cin>>a[i];

    ll c2=2*n,c4=n;

    F(i,1,k){
        if(a[i]>=4){
            while(c4>0 && a[i]>=4) c4-=1,a[i]-=4;
            while(a[i]>=4) c2-=2,a[i]-=4;
        }
    }

    F(i,1,k){
        if(a[i]==3){
            if(c4>0) c4-=1;
            else c2-=2;
            a[i]=0;
        }
    }

    ll sgl=0,tl=0;
    F(i,1,k){
        if(a[i]==2){
            if(c2>0) c2--;
            else if(c4>0) c4--,sgl++;
            else tl+=2;
        }
        else if(a[i]==1) tl++;
    }
    if(c4<0 || c2<0) out("NO");

    sgl+=c4*2+c2;

    if(tl>sgl) out("NO");
    cout<<"YES"<<endl;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int a[k];
    for (int i = 0; i < k; ++i)
        cin>>a[i];
    bool f[n],t1[n],t2[n];
    memset(f,2,sizeof(f)),memset(t1,1,sizeof(t1)),memset(t2,1,sizeof(t2));
    for (int j = 0; j < n; ++j)
        for (int i = 0; i < k; ++i)
            if(a[i]>=4){
                a[i]-=4;f[j]=0;break;
            }
    for (int j = 0; j < n; ++j)
        for (int i = 0; i < k; ++i)
            if(a[i]>=2&&f[j]){
                a[i]-=2;f[j]=1;break;
            }
    for (int j = 0; j < n; ++j)
        for (int i = 0; i < k; ++i)
            if(a[i]>=2){
                a[i]-=2;t1[j]=0;break;
            }
    for (int j = 0; j < n; ++j)
        for (int i = 0; i < k; ++i)
            if(a[i]>=2){
                a[i]-=2;t2[j]=0;break;
            }
    int left=0,sum=0;
    for (int i = 0; i < n; ++i)
        left+=f[i]+t1[i]+t2[i];
    for (int i = 0; i < k; ++i)
        sum+=a[i];
    if(sum<=left)   cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

string solution(vector<int> group_people, int rows)
{
    int middle_seats = rows;

    int other_seats = rows * 2;

    int seats_for_one = 0;

    int remain_4 = 0;
    int remain_1 = 0;
    int remain_2 = 0;
    int remain_3 = 0;

    for(int group : group_people)
    {
        remain_4 += group / 4;
        if(group % 4 == 0)
        {

        }
        else if(group % 4 == 1)
        {
            ++remain_1;
        }
        else if(group % 4 == 2)
        {
            ++remain_2;
        }
        else
        {
            ++remain_3;
        }
    }

    //first arrange those four_group
    int temp1 = min(remain_4, middle_seats);
    remain_4 -= temp1;
    middle_seats -= temp1;

    int temp2 = min(remain_4, other_seats / 2);
    int temp3 = min(remain_4 * 2, other_seats);
    remain_4 -= temp2;
    other_seats -= temp3;

    if(remain_4 != 0)
    {
        return "NO";
    }

    //remain_4 should be 0, handle remain_3
    int temp4 = min(middle_seats, remain_3);
    remain_3 -= temp4;
    middle_seats -= temp4;

    //if still has remain_3, need to arrage to two_seat
    int temp5 = min(other_seats, remain_3);
    remain_3 -= temp5;
    other_seats -= temp5;
    remain_1 += temp5;

    if(remain_3 != 0)
    {
        return "NO";
    }

    //handle remain_2
    int temp6 = min(middle_seats, remain_2);
    middle_seats -= temp6;
    remain_2 -= temp6;
    seats_for_one += temp6;

    int temp7 = min(other_seats, remain_2);
    other_seats -= temp7;
    remain_2 -= temp7;

    if(remain_2 > 0)
    {
        remain_1 += remain_2 * 2;
    }

    if(seats_for_one + middle_seats * 2 + other_seats >= remain_1)
    {
        return "YES";
    }
    else
    {
        return "NO";
    }

}

int main()
{
    int rows;
    int groups;
    cin >> rows >> groups;

    vector<int> group_people;
    for(int i = 0; i < groups; ++i)
    {
        int temp;
        cin >> temp;
        group_people.push_back(temp);
    }

    cout << solution(group_people, rows) << endl;
    return 0;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>

#define MAX 10005
using namespace std;
int main( )
{
    int n,m;
    while(cin >> n >> m){
        int seat4 = n,seat2 = n*2,seat1 = 0;
        int need_seat4,need_seat2;
        for(int j = 0; j < m; j++){
            int a;
            cin >> a;
            while(a > 0){
                if(seat4 > 0 && a >= 3)
                    seat4--,a -= 4;
                else if(seat2 > 0 && a >= 2)
                    seat2--,a -= 2;
                else if(a == 1)
                    seat1--,a--;
                else if(seat4 > 0)
                    seat4--,a -= 2,seat1++;
                else seat1--,a--;
            }
        }
        if(seat4 >= 0 && seat4*2 + seat2 + seat1 >= 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define MEM(a,b) memset(a,b,sizeof(a))
#define bug puts("bug");
#define PB push_back
#define MP make_pair
#define X first
#define Y second
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+10;
using namespace std;
int n,k,a[maxn];

int main(){
    cin>>k>>n;
    ll sum=0,yu[3];
    yu[2]=yu[1]=0;
    int four=k,two=k*2;
    for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
    for(int i=0;i<n;i++){
        while(four>0&&a[i]>=4) a[i]-=4,four--;
        while(two>0&&a[i]>=2) a[i]-=2,two--;
        if(four>0&&a[i]==3) four--,two++,a[i]-=2;
        if(a[i]>2) goto bd;
        yu[a[i]]++;
    }
    if(yu[2]>=four) yu[1]+=(yu[2]-four)*2,two+=four;
    else two+=four*2-yu[2];
    if(yu[1]>two) puts("NO");
    else puts("YES");
    return 0;
    bd: puts("NO");
}

#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include<sstream>
#include <math.h>
using namespace std;
int a[100000];
void main() {
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> a[i];
	}
	sort(a, a + k);
	int c = n;
	bool ok = true;
	for (int i = k - 1; i >= 0; i--)
	{
		if (c - a[i] / 4 >= 0)
		{
			c -= a[i] / 4;
			a[i] = a[i] % 4;
		}
		else
		{
			a[i] = a[i] - c * 4;
			c = 0;
		}
		if (c == 0)
		{
			break;
		}
	}
	int one = 0, two = 0;
	for (int i = 0; i<k; i++)
	{
		two += a[i] / 2;
		one += a[i] % 2;
	}
	int k2 = 0;
	if (two <= 2 * n)
	{
		k2 = 2 * n - two;
		two = 0;
	}
	else
	{
		two -= 2 * n;
		if (two <= c)
		{
			c = c - two;
			k2 = two;
			two = 0;
		}
		else
		{
			one += (two - c) * 2;
			k2 =c;
			c = 0;
			two = 0;
		}
	}
	k2 += c * 2;
	if (k2 < one)
	{
		ok = false;
	}
	if (ok)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <random>

using namespace std;

typedef long long ll;

ll INF = 1e18;
int INFi = 2e9;
double eps = 1e-6;
ll mod = 998244353;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

	int n, k;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int f4 = k;
	int f2 = 2 * k;
	for (int i = 0; i < n; i++) {
		while (a[i] >= 4 && f4) {
			f4--;
			a[i] -= 4;
		}
		while (a[i] >= 4 && f2 >= 2) {
			a[i] -= 4;
			f2 -= 2;
		}
		if (a[i] >= 4) {
			cout << "NO\n";
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		//cout << a[i] << " " << f4 << " " << f2 << endl;
		if (a[i] >= 3 && f4) {
			f4--;
			a[i] -= 3;
		}
		if (a[i] >= 3 && f2 >= 2) {
			f2 -= 2;
			a[i] -= 3;
		}
		if (a[i] >= 3) {
			cout << "NO\n";
			return 0;
		}
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	while (!a.empty() && a.back() == 0) a.pop_back();
	int l = 0, r = a.size() - 1;
	while (f4 && r - l > 0 && a[l] == 2 && a[r] == 1) {
		//cout << f4 << " " << l << " " << r << endl;
		f4--;
		a[r] -= 1;
		a[l] -= 2;
		r--;
		l++;
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	while (!a.empty() && a.back() == 0) a.pop_back();
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 2) {
			if (f2) {
				f2--;
				a[i] -= 2;
			}
			else if (f4) {
				if (f4 >= 2 && i < a.size() - 2) {
					f4 -= 2;
					a[i] -= 2; a[i + 1] -= 2; a[i + 2] -= 2;
					i += 2;
				}
				else {
					f4--;
					a[i] -= 2;
				}
			}
			else {
				cout << "NO\n";
				//system("pause");
				return 0;
			}
		}
		else {
			if (f4) {
				if (i != a.size() - 1) {
					i++;
					f4--;
					a[i]--;
					a[i + 1]--;
				}
				else {
					f4--;
					a[i]--;
				}
			}
			else if (f2) {
				f2--;
				a[i]--;
			}
			else {
				cout << "NO\n";
				//system("pause");
				return 0;
			}
		}
	}
	cout << "YES\n";
	//system("pause");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n,k,x;
	while(scanf("%d%d",&n,&k)==2)
	{
		int two=n*2,four=n;

		int a=0,b=0;

		for(int i=0;i<k;i++)
		{
			scanf("%d",&x);

			int tmp=(x+1)/4;

			if(four>=tmp) four-=tmp;
			else
			{
				tmp-=four; four=0;

				tmp*=2;

				if(two>=tmp) two-=tmp;
				else tmp-=two,two=0,b+=tmp;
 			}

			if(x%4==1) a++;
			else if(x%4==2) b++;
		}

		int c=min(four,min(a,b));

		a-=c;
		b-=c;
		four-=c;

		if(a==0)
		{
			if(four%2==0) four=four/2*3;
			else four=four/2*3+1;
			if(b<=four+two) printf("YES\n");
			else printf("NO\n");
		}
		else if(b==0)
		{
			if(a<=four*2+two) printf("YES\n");
			else printf("NO\n");
		}
		else if(four==0)
		{
			if(a+b<=two) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}

#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<map>
#include<queue>
#include<stack>
#include<vector>

using namespace std;

#define MOD 1000000007
#define INF 2147483647
#define NINF -INF
#define x first
#define y second

int n,k,a[10005],t,f,o;

int main() {
	scanf("%d%d", &n, &k);
	f = n;
	for (int i = 0; i < k; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < k; i++) {
		if (a[i] >= 4) {
			if (f >= a[i] / 4) {
				f -= a[i] / 4;
				a[i] %= 4;
			}
			else {
				a[i] -= f * 4;
				f = 0;
			}
		}
	}
	t = n * 2 + f;
	for (int i = 0; i < k; i++) {
		if (a[i] >= 2) {
			if (t >= a[i] / 2) {
				t -= a[i] / 2;
				a[i] %= 2;
			}
			else {
				a[i] -= t * 2;
				t = 0;
			}
		}
	}
	o = f + t;
	for (int i = 0; i < k; i++) {
			if (o >= a[i]) {
				o -= a[i];
				a[i] = 0;
			}
			else {
				a[i] -= o;
				o = 0;
			}
	}
	for (int i = 0; i < k; i++) {
		if (a[i] > 0) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int etwo, eone;

int main()
{
	int N, K;
	cin >> N >> K;
	int fours = N;
	int twos = 2 * N;
	for (int i = 1; i <= K; i++) {
		int A;
		cin >> A;
		int four = A / 4;

		int temp = min(four, fours);
		four -= temp;
		fours -= temp;

		int extTwo = four * 2;
		if (extTwo > twos) {
			cout << "NO\n";
			return 0;
		}
		twos -= extTwo;

		if (A % 4 == 3) {
			if (fours) {
				fours--;
			} else {
				if (twos >= 1) {
					twos--;
					eone++;
				} else {
					etwo++;
					eone++;
				}
			}
		} else if (A % 4 == 2) {
			if (twos) {
				twos--;
			} else {
				etwo++;
			}
		} else if (A % 4 == 1) {
			eone++;
		}
	}

	int take = min(eone, twos);
	eone -= take;
	twos -= take;

	if (eone + etwo == 0) {
		cout << "YES\n";
		return 0;
	} else if (fours == 0) {
		cout << "NO\n";
		return 0;
	}
	take = min(fours, min(etwo, eone));
	fours -= take;
	etwo -= take;
	eone -= take;

	if (eone + etwo == 0) {
		cout << "YES\n";
		return 0;
	} else if (fours == 0) {
		cout << "NO\n";
		return 0;
	}

	if (etwo == 0) {
		if (fours * 2 >= eone) {
			cout << "YES\n";
			return 0;
		} else {
			cout << "NO\n";
			return 0;
		}
	} else {
		if (fours >= etwo || fours >= (etwo - fours) * 2) {
			cout << "YES\n";
			return 0;
		} else {
			cout << "NO\n";
			return 0;
		}
	}
}

#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n, k, even[100], odd[100], tabx[10000][8];
bool s = false;
int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	int o = 0;
	int e = 0;
	for (int i = 0; i < k; i++)
	{
		int x;
		cin >> x;
		if (x % 2 == 0)
		{
			even[e] = x;
			e++;
		}
		else
		{
			odd[o] = x;
			o++;
		}
	}
	sort(even, even + e);
	sort(odd, odd + o);

	for (int i = 0; i < e; i++)
	{
		for (int p = 0; p < n; p++)
		{
			for (int a = 0; a < 4; a++)
			{
				if (a == 0)
				{
					if (tabx[p][0] == 0)
					{
						tabx[p][0] = i + 1;
						even[i]--;
					}
				}
				if (a == 1)
				{
					if (tabx[p][0] == i + 1 && tabx[p][1] == 0)
					{
						tabx[p][1] = i + 1;
						even[i]--;
					}
				}
				if (a == 2)
				{
					if (tabx[p][6] == 0)
					{
						tabx[p][6] = i + 1;
						even[i]--;
					}
				}
				if (a == 3)
				{
					if (tabx[p][6] == i + 1 && tabx[p][7] == 0)
					{
						tabx[p][7] = i + 1;
						even[i]--;
					}
				}
				if (even[i] == 0)break;
			}
			if (even[i] == 0)break;
		}
		if (even[i] != 0)

		{
			for (int p = 0; p < n; p++)
			{
				for (int a = 2; a < 6; a++)
				{
					if (tabx[p][a] == 0)
					{
						if (a == 2)
						{
							even[i]--;
							tabx[p][a] = i + 1;
							if (even[i] == 0)break;
						}
						else
						{
							if (a == 5)
							{
								if (tabx[p][a] == 0 && (tabx[p][a - 1] == 0 || tabx[p][a - 1] == i + 1))
								{
									even[i]--;
									tabx[p][a] = i + 1;
									if (even[i] == 0)break;
								}
							}
							else
							{

								if ((tabx[p][a - 1] == 0 || tabx[p][a - 1] == i + 1) && tabx[p][a + 1] == 0)
								{
									even[i]--;
									tabx[p][a] = i + 1;
									if (even[i] == 0)break;
								}
							}
						}
					}
					else
					{
						if (p == n - 1)
						{
							if (s == false)
							{
								p = 0;
								s = true;
							}
						}
						else
						{
							if(s==false)
							break;
						}
					}
				}
				if (even[i] == 0)break;
			}
		}
	}
	for (int i = 0; i < o; i++)
	{

		for (int p = 0; p < n; p++)
		{
			for (int a = 0; a < 4; a++)
			{
				if (a == 0)
				{
					if (tabx[p][0] == 0)
					{
						tabx[p][0] = i + 1;
						odd[i]--;
					}
				}
				if (odd[i] == 0)break;
				if (a == 1)
				{
					if (tabx[p][0] == i + 1 && tabx[p][1] == 0)
					{
						tabx[p][1] = i + 1;
						odd[i]--;
					}
				}
				if (odd[i] == 0)break;
				if (a == 2)
				{
					if (tabx[p][6] == 0)
					{
						tabx[p][6] = i + 1;
						odd[i]--;
					}
				}
				if (odd[i] == 0)break;
				if (a == 3)
				{
					if (tabx[p][6] == i + 1 && tabx[p][7] == 0)
					{
						tabx[p][7] = i + 1;
						odd[i]--;
					}
				}
				if (odd[i] == 0)break;
			}
			if (odd[i] == 0)break;
		}
		if (odd[i] != 0)
		{
			for (int p = 0; p < n; p++)
			{
				for (int a = 2; a < 6; a++)
				{
					if (tabx[p][a] == 0)
					{
						if (a == 2)
						{
							odd[i]--;
							tabx[p][a] = i + 1;
							if (odd[i] == 0)break;
						}
						else
						{
							if (a == 5)
							{
								if (tabx[p][a] == 0 && (tabx[p][a - 1] == 0 || tabx[p][a - 1] == i + 1))
								{
									odd[i]--;
									tabx[p][a] = i + 1;
									if (odd[i] == 0)break;
								}
							}
							else
							{

								if ((tabx[p][a - 1] == 0 || tabx[p][a - 1] == i + 1) && tabx[p][a + 1] == 0)
								{
									odd[i]--;
									tabx[p][a] = i + 1;
									if (odd[i] == 0)break;
								}
							}
						}
					}
					else
					{

					}
				}
				if (odd[i] == 0)break;
			}
		}

	}
	for (int i = 0; i < e; i++)
		if (even[i] > 0)
		{
			cout << "No";
			return 0;
		}
	for (int i = 0; i < o; i++)
		if (odd[i] > 0)
		{
			cout << "No";
			return 0;
		}
	cout << "Yes";

	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
#define lcm(a,b) a*b/__gcd(a,b)
#define sz(x) (int)x.size()
#define cmp complex<double>
int power(int x,int y,int m){
    int res=1;
    while(y>0){
        if(y&1)res=(res*x)%m;
        x=(x*x)%m;
        y/=2;
    }
    return res;
}
void precompute(){
}
void solve(int tc){
    int n,k;
    cin>>n>>k;
    vector<int> v(k);
    int occ=0;
    for(int i=0;i<k;i++){
        cin>>v[i];
        occ+=v[i]/4;
        v[i]=v[i]%4;
    }
    int fos=0,tos=0;
    if(occ<=n){
        fos=n-occ;
        tos=2*n;
    }
    else tos=2*n-2*(occ-n);
    for(int i=0;i<k;i++){
        if(!v[i])continue;
        if(tos==0){
            break;
        }
        if(v[i]>=2)v[i]-=2,tos-=1;
    }
    sort(v.begin(),v.end(),greater<int>());
    int on=0;
    for(int i=0;i<k;i++){
        if(!v[i])continue;
        if(tos==0 && on==0 && fos==0){
            cout<<"NO";
            return;
        }
        if(v[i]==2){
            if(fos==0 && on<2){
                cout<<"NO";return;
            }
            if(fos){
            fos-=1;
            on+=1;
            }
            else on-=2;
        }
        if(v[i]==3){
            if(fos==0 && on<3){
                cout<<"NO";return;
            }
            if(fos){
                fos-=1;
            }
            else on-=3;
        }
        if(v[i]==1){
            if(on)on-=1;
            else if(tos)tos-=1;
            else {
                fos-=1;
                on+=1;
            }
        }
    }
    cout<<"YES";
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(12);
    int t=1,ctr=0;
    // precompute();
    // cin>>t;
    while(t--){
        solve(ctr+1);
        ctr++;
    }
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f
#define rep0(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define rep_0(i, n) for (int i = n - 1; i >= 0; i--)
#define rep_1(i, n) for (int i = n; i > 0; i--)
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define mem(x, y) memset(x, y, sizeof(x))

#define MAXK 110
using namespace std;
int A[MAXK];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int n, k, cnt = 0;
    cin >> n >> k;
    int flag = 1, tmp = 0, tmp1 = 0;
    int a = n * 2, b = n, cnt4 = 0, cnt2 = 0, cnt1 = 0;
    n *= 8;
    for (int i = 0; i < k; i++)
    {
        cin >> A[i];
        cnt4 += A[i] / 4;
        A[i] %= 4;
        cnt2 += A[i] / 2;
        A[i] %= 2;
        cnt1 += A[i];

    }
    //cout << cnt4 << "   " << cnt2 << "   " << cnt1 << endl;
    if (b >= cnt4)
    {
        b -= cnt4;
    }
    else
    {

        a -= (cnt4 - b) * 2;
        b = 0;
        //cout << cnt4 - b << endl;
    }

    if (a < 0)
    {
        cout << "NO" << endl;
        return 0;
    }

    if (cnt1 < cnt2)
    {
        if (b >= cnt1)
        {
            b -= cnt1;

        }
        else
        {
            a -= cnt1 * 2;

        }
        cnt2 -= cnt1;
        //cout << cnt2 << "   " << a << "   " << b << endl;
        if (a >= cnt2)
        {
            cout << "YES" << endl;
            return 0;
        }
        else
        {
            cnt2 -= a;
            //cout << cnt2 << endl;
            if (cnt2 <= b)
            {
                cout << "YES" << endl;
                return 0;
            }
            else if ((cnt2 - b) * 2 <= b)
            {
                cout << "YES" << endl;
                return 0;
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }
        }

    }
    else
    {
        if (b >= cnt2)
        {
            b -= cnt2;

        }
        else
        {
            a -= cnt2 * 2;

        }

        cnt1 -= cnt2;

        if (a + 2 * b >= cnt1)
        {
            cout << "YES" << endl;
            return 0;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }

    }

    return 0;
}

                #include<bits/stdc++.h>
            using namespace std;
            # define ll long long
            # define int long long  //comment it out when MLE
            # define endl "\n"
           // template <typename T>
            //using ordered_set = tree<T, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

            #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
            //# define m 163577857
            # define mo 1000000007
            # define pi acos(-1)
           # define fi first
            # define se second
            # define pb push_back
            # define pii pair<int,int>
            #define REP(i,n) for (int i = 1; i <= n; i++)
            const int mod =  1000000007;
            //const int K = 2;
            //typedef vector<vector<int> > matrix;
/*
          int add(int a, int b,int mod) {
                a%=mod;
                b%=mod;
                a += b;
                if (a >= mod) a -= mod;
                if(a<0)
                {
                    a += mod;
                    a %= mod;
                }
                return a;
            }

            int mul(ll a, int b,int mod) {
                a%=mod;
                b%=mod;
                a *= b;
                a += mod;
                return a % mod;
            }
            int po(int a,int b,int mod)
            {
                if(b==0)
                    return 1;
                if(b%2==0)
                    return po(mul(a,a,mod),b/2,mod);
                return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
            }

            ll fact[200003];
            ll inv[200003];

            void fact0()
            {
                int i,j;
                fact[0]=1;
                for(i=1;i<=200000;i++)
                {
                    fact[i]=i*fact[i-1]%mod;
                }
                inv[0]=1;
                inv[1]=1;
                ll p=mod;
                for (i=2; i<=200000; i++)
                    inv[i] = (p - (p/i) * inv[p%i] % p) % p;

                for(i=2;i<=200000;i++)
                {
                    inv[i]*=inv[i-1];
                    inv[i]%=mod;
                }
            }
            int help(int a,int b)
            {
               // cout<<a<<" "<<b<<endl;
                int an = fact[a];
                //cout<<an<<endl;
                an *= inv[b];
                an %= mod;
                an *= inv[a-b];
                an %= mod;
                return an;
            }
/*
          void random()
            {
              srand(time(0));
            for (int i = 0; i < n; i ++)
                perm[i] = i + 1;
            random_shuffle(perm, perm + n);
            }
int ncr(int a,int b)
{
    int tt = fact[a];
    tt %= mod;
    tt *= inv[a-b];
    tt %= mod;
    tt *= inv[b];
    tt %= mod;
    return tt;
}
*/

signed main(){
	gok

 int n,k;
 cin>>n>>k;
 int a[k];
 for(int i=0;i<k;i++)
    cin>>a[i];

 int c1=2*n,c2=n;
 bool ch=true;
 sort(a,a+k);
 reverse(a,a+k);
 int cc1=0,cc2=0,cc3=0;
 for(int i=0;i<k;i++)
 {
     if(a[i]>=4)
     {
         int mi = min(a[i]/4,c2);
         c2-=mi;
         a[i]-=4*mi;
     }
 }
 for(int i=0;i<k;i++)
 {
    if(c1>=a[i]/2)
    {
        c1 -= a[i]/2;
        a[i]%=2;
        if(a[i]==1)
            cc1++;
    }
    else
    {
        if(c2>=a[i]/4)
        {
            c2 -= a[i]/4;
            a[i]%=4;
            if(a[i]==1)
                cc1++;
            else if(a[i]==2)
                cc2++;
            else if(a[i]==3)
                c2--;
                if(c2<0)
                {
                    ch=false;
                    break;
                }
        }
    }
 }

    int mi = min(cc1,cc2);
    int m2 = min(mi,c2);
    cc1-=m2;
    cc2-=m2;
    c2-=m2;
    if(c2==0)
    {
        if(cc1+cc2>c1)
            ch=false;
    }
    else
    {
        if(cc1>0)
        {
            if(2*c2+c1<cc1)
                ch=false;
        }
        else if(cc2>0)
        {
            if(c2+c1+(c2/2)<cc2)
                ch=false;
        }
    }

 if(ch)
    cout<<"YES";
 else
    cout<<"NO";

  return 0;
}

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define INF 1e8
#define pr 998244353
#define endl "\n"
//#define ordered_set tree<pair<int,int>, nuint_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>

int power(int x,int y)
{
    if(y==0)return 1;
    if(y%2)return (x%MOD * power(x,y-1)%MOD)%MOD;
    else return power((x*x)%MOD,y/2)%MOD;
}

int n, k, have[5], cnt[5];
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	have[2] = 2 * n, have[4] = n;
	for(int i = 0; i < k; i++){
		int x;
		cin >> x;
		while(x >= 3)
			if(have[4] > 0)
				x -= 4, have[4]--;
			else if(have[2] > 0)
				x -= 2, have[2]--;
			else
				return cout << "NO" << '\n', 0;
		if(x > 0)
			cnt[x]++;
	}
	while(cnt[2])
		if(have[2] > 0)
			cnt[2]--, have[2]--;
		else if(have[4] > 0)
			cnt[2]--, have[4]--, have[1]++;
		else
            cnt[2]--, cnt[1] += 2;
	if(cnt[1] > have[1] + have[2] + have[4] * 2)
		return cout << "NO" << '\n', 0;
	cout << "YES" << '\n';
	return 0;

}

#include "iostream"
#include <math.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int grps[k], i =0;
    int max_grps = 4*n, singles = 0,total=0;
    while(k > i){
        cin >> grps[i];
        max_grps = max_grps - floor(grps[i]/2);
        singles = singles + grps[i]%2;
        total =total + grps[i];
        if(max_grps <= 0 && i != k - 1){
        //    cout << "here : 1" << endl;
            cout << "NO";
            return 0;
        }
        i++;
    }
    //cout << "singles " << singles << "max_grps: " << max_grps << endl;
 	if((k*2==n*8 && total==k*2) ||(k*2==n*8 && singles<n))
 	{
 		cout<<"NO";
 		return 0;
 	}
    if(singles > max_grps)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include   <iostream>
#include   <algorithm>
#include   <queue>
#include   <cstdio>
#include   <vector>
#include   <deque>
#include   <map>
#include   <set>
#include   <string>
#include   <deque>
#include   <cmath>
#include   <stack>
#include   <unordered_map>
#include   <cstring>

#define   mp   make_pair

using namespace std;

const int N = 444444;
long long mod = 1000 * 1000 * 1000 + 7;

using namespace std;

int main() {
	int n, k;
	cin >> k >> n;
	int q1 = k;
	int q2 = 2 * k;
	int q4 = 0;
	for (int i = 1; i <= n; ++i) {
		int a1;
		cin >> a1;
		while (a1 >= 4 && q1 > 0) {
			q1--; a1 -= 4;
		}
		while (a1 >= 2 && q2 > 0) {
			q2--; a1 -= 2;
		}
		while (a1 >= 4 && q4 > 0) {
			a1--; q4--;
		}
		if (a1 >= 4) {
			cout << "NO" << endl; return 0;
		}
		if (a1 == 1) {
			if (q4 > 0)q4--;
			else if (q1 > 0) { q1--; q2++; }
			else {
				if (q2 > 0) { q2--; }
				else {
					cout << "NO" << endl; return 0;
				}
			}
		}
		else if(a1==2){
			if (q2 > 0)q2--;
			else if (q1 > 0) {
				q1--; q4++;
			}
			else {
				if (q4 > 1) { q4 -= 2; }
				else {
					cout << "NO" << endl; return 0;
				}
			}
		}
		else if (a1 == 3) {
			if (q1 > 0)q1 --;
			else if (q2 > 0 && q4 > 0) { q2--; q4--; }
			else if (q2 > 1)q2 -= 2;
			else if (q4 > 2)q4 -= 3;
			else {
					cout << "NO" << endl; return 0;
			}
		}
	}
	cout << "YES" << endl;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int fourPair;
int twoPair;
int onePair;
int input;
priority_queue<int> pq;

void one1()
{
    if(!input)
	return;
    int tot = min(input, onePair);
    input -= tot;
    onePair -= tot;
}

void two2()
{
    if(!input)
	return;
    int tot = min(input/2, twoPair);
    input -= 2*tot;
    twoPair -= tot;
    onePair -= tot;
    if(input && twoPair)
    {
	twoPair--;
	onePair--;
	input = 0;
    }
    one1();
}

void four4()
{
    if(!input)
	return;
    int tot = min(input/4, fourPair);
    input -= 4*tot;
    fourPair -= tot;
    twoPair -= tot;
    onePair -= 2*tot;
    if(input && fourPair)
    {
	if(input == 2)
	    onePair++;
	if(input == 1)
	{
	    twoPair++;
	    onePair++;
	}

	twoPair--;
	fourPair--;
	onePair -= 2;
	input = 0;
    }
    two2();
}

int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; i++)
    {
	int id;
	cin >> id;
	pq.push(id);
    }
//    cout << n << endl;
    fourPair = n;
    twoPair = n*3;
    onePair = n*4;
    while(!pq.empty())
    {
	input = pq.top();
	pq.pop();
//	cout << input << " "<< fourPair << " " << twoPair << " " << onePair << endl;
	if(fourPair && input)
	    four4();
//	cout << input << " " << fourPair << " " << twoPair << " " << onePair << endl;
	if(twoPair && input)
	    two2();
//	cout << input << " " << fourPair << " " << twoPair << " " << onePair << endl;
	if(onePair && input)
	    one1();
//	cout << input << " "<<fourPair << " " << twoPair << " " << onePair << endl;
	if(input)
	{
	    cout << "NO\n";
	    return 0;
	}
//	cout << endl;
    }
    cout << "YES\n";
    return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int n,m,four,two,one,ans1,ans2;
int main()
{
    int i,j;
    scanf("%d%d",&m,&n);
    ans1=m;ans2=m*2;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&j);
        four+=j/4;j%=4;
        two+=j/2;j%=2;
        one+=j;
    }
    while(four>0&&ans1>0)ans1--,four--;
    two+=four*2;four=0;
    int ans=ans1+ans2;
    while(two>0&&ans>0)ans--,two--;
    ans+=ans1;
    one+=two*2;two=0;
    while(one>0&&ans>0)ans--,one--;
    if(two||four||one)printf("NO\n");
    else printf("YES\n");
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	int slots[5];
	slots[4] = n;
	slots[2] = 2*n;
	slots[1] = 0;
	slots[0] = 0;
	int rem[3] = {0,0,0};
	for (int j=0;j<k;j++)
	{
		int x;
		cin >> x;
		while (x>=3)
		{
			//For greater than 3 why we can not have slots of 1 ???? . Let us try that
			if (slots[4]>0)
			{
				slots[4]--;
				x -= 4;
			}
			else if (slots[2]>0)
			{
				slots[2]--;
				x -= 2;
			}
			else if (slots[1]>0)
			{
				slots[1]--;
				x -= 1;
			}
			else
			{
				cout <<"NO\n";
				return 0;
			}
		}
		if (x>0)
		{
			rem[x]++;
		}
	}
	while (rem[2]!=0)
	{
		if (slots[2]>0)
		{
			slots[2]--;
			rem[2]--;
		}
		else if (slots[4]>0)
		{
			slots[4]--;
			slots[1]++;
			rem[2]--;
		}
		else if (slots[1]>0)
		{
			slots[1]--;
			rem[1]++;
			rem[2]--;
		}
		else
		{
			cout <<"NO\n";
			return 0;
		}
	}
	if (rem[1]>(slots[4]*2+slots[2]+slots[1]))
	{
		cout <<"NO\n";
		return 0;
	}
	cout <<"YES\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,x;
    cin>>n>>k;
    int t=0,yo=0;
    for(int i=0;i<k;i++)
    {
        cin>>x;
        if(x%2!=0)yo++,t+=x+1;
        else t+=x;
    }

    if(t>8*n || (t==8*n && k==4*n && yo<n))cout<<"NO";
    else cout<<"YES";
}

/*****************
 *   I<3   C++   *
 *  IWANT ANYAC  *
 * ILOVEPROGRAM! *
 *IT'SINTERESTING*
 * ILOVEPROGRAM! *
 *  INCONTESTS   *
 *   GETSCORE    *
 *    ACCODE     *
 *     LETS      *
 *      GO       *
 *****************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,k,a[100007];
int have[10050][5],hzz=0;
int cn4,cn2,cn1,sum=0;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		scanf("%d",a+i);
		sum+=a[i];
		while(a[i]>=4)cn4++,a[i]-=4;
		if(a[i]>=2)cn2++,a[i]-=2;
		if(a[i]>=1)cn1++,a[i]-=1;
	}
	if(sum+cn1>n*8)OVER("NO");
	int c1=hzz,c2=hzz,c3=hzz,c4=hzz;
	int i;
	for(i=0;c2<n&&i<cn4;c2++,c3++,i++)
		have[c2][2]=have[c3][3]=1;
	for(;c1<n&&i<cn4;c1++,c4++,i++)
		have[c1][1]=have[c4][4]=1;
	for(;i<cn4;i++)cn2+=2;
	for(i=0;c1<n&&i<cn2;c1++,i++)
		have[c1][1]=1;
	for(;c2<n&&i<cn2;c2++,i++)
		have[c2][2]=1;
	for(;c4<n&&i<cn2;c4++,i++)
		have[c4][4]=1;
	for(;i<cn2;i++)cn1+=2;
	for(i=0;c1<n&&i<cn1;c1++,i++)
		have[c1][1]=1;
	for(;c2<n&&i<cn1;c2++,i++)
		have[c2][2]=1;
	for(;c3<n&&i<cn1;c3++,i++)
		have[c3][3]=1;
	for(;c4<n&&i<cn1;c4++,i++)
		have[c4][4]=1;
	if(i!=cn1)OVER("NO");
	OVER("YES");
}

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN=10005;
int a[MAXN];
int left[5];
int main(){
  	int n,k,p;
  	memset(a,0,sizeof(a));
  	memset(left,0,sizeof(left));
  	scanf("%d%d",&n,&k);
  	left[4]=n,left[2]=n*2;
  	for(int i=0;i<k;i++){
  		scanf("%d",&p);
  		a[p]++;
  	}
  	for(int i=10000;i>0;i--){
  		while(a[i]--){
            int ok=0;
            for(int j=4;j>=1&&!ok;j--){
                if(left[j]){
                    left[j]--;
                    ok=1;
                    int tt=min(j,i);
                    if(i-tt>0)
                        a[i-tt]++;
                    if(j==4){
                        if(tt==1)
                            left[2]++;
                        else if(tt==2)
                            left[1]++;
                    }
                }
            }
            if(!ok){
                printf("NO\n");
                return 0;
            }
  		}
  	}
  	printf("YES\n");
  	return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<int,string> mis;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef stack<int> si;
typedef stack<ll> sl;

#define MAX 100000
#define mod 1000000007
#define make_pair MP
#define PB push_back
#define F first
#define S second
#define sl(a) scanf("%I64d",&a)
#define si(a) scanf("%d",&a)
#define pl(a,s) printf("%I64d%s",a,s)
#define pi(a,s) printf("%d%s",a,s)
#define FOR(i,a,n) for(int i=(a) ; i<n ; i++)
#define rep(i,n) FOR(i,0,n)
#define mem(a,b) memset(a,b,sizeof(a))

bool compk(pii a,pii b)
{
    return a.F<b.F;
}

main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;

    int grp[k];
    int mcnt=n,fcnt=n*2,one=0;
    for(int i=0 ; i<k ; i++) cin>>grp[i];

    //sort(grp,grp+k);

    //cout<<mcnt<<" "<<fcnt<<endl;
    for(int i=0 ; i<k ; i++)
    {
        while(grp[i]>=3)
        {
            if(mcnt)
                grp[i] -= 4,mcnt--;
            else if(fcnt>=2)
                grp[i] -= 4,fcnt-=2;
            else if(one>=grp[i])
                grp[i]=0,one-=4;
            else
                return cout<<"NO"<<'\n',0;
        }

        while(grp[i]==2)
        {
            if(fcnt>0)
                grp[i]-=2,fcnt--;
            else if(mcnt>0)
            {
                mcnt--;
                one+=(grp[i]==2),grp[i]=0;
            }
            else if(one>=grp[i])
                one-=grp[i],grp[i]=0;
            else
                return cout<<"NO"<<'\n',0;
        }

        if(grp[i]==1)
            if(one)
                one--;
            else if(mcnt)
                mcnt--,fcnt++;
            else if(fcnt)
                fcnt--;
            else
                return cout<<"NO"<<'\n',0;
    }

    cout<<"YES"<<endl;
}

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	ll n,k;
	cin>>n>>k;
	ll a[k],ans=0,sum=0;
	for (int i = 0; i < k; ++i){
		cin>>a[i];
		if(a[i]%2==1)
			ans++;
		sum+=a[i];
	}
	if((8*n)>(sum+ans))
		cout<<"YES\n";
	else if((8*n)==(sum+ans) && ans!=0 && k<=3*n+ans)
		cout<<"YES\n";
	else if((8*n)==(sum+ans) && k<=3*n)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

#include<iostream>
using namespace std;
int k, n;
int tmp;
int need4, need2, need1;
int sum2;
int sum1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < k; i++)
	{
		cin >> tmp;
		need4 += tmp / 4, tmp %= 4;
		need2 += tmp / 2, tmp %= 2;
		need1 += tmp;
	}
	sum2 = 2 * n;
	sum1 = 0;
	if(need4 <= n)
		sum2 += n - need4, sum1 += n - need4;
	else
		sum2 -= (need4 - n) * 2;
   	if(need2 <= sum2)
		sum1 += sum2 - need2;
	else
		sum1 -= (need2 - sum2) * 2;
	if(sum1 >= need1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

/* In the name of Allah */

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>

int main()
{
  int n, k;
  cin >> n >> k;
  int cnt_1 = 0;
  int cnt_2 = 0;
  int cnt_3 = 0;
  int cnt_4 = 0;

  for(int i = 0; i < k; i++){
    int x;
    cin >> x;
    cnt_4 += x/4;
    if(x%4 == 1) cnt_1++;
    else if(x%4 == 2) cnt_2++;
    else if(x%4 == 3) cnt_3++;
  }

  int rem_4 = n-min(n, cnt_4);
  cnt_2 += max(0, cnt_4 - min(n, cnt_4))*2;
  cnt_4 = 0;

  int z = rem_4;
  if(rem_4)
    rem_4 -= min(rem_4, cnt_3);

  cnt_3 = max(0, cnt_3 - min(z, cnt_3));

  int zz = min(cnt_1, cnt_2);
  z = min(rem_4, zz);
  if(rem_4)
    rem_4 -= z;

  cnt_1 -= z;
  cnt_2 -= z;

  z = cnt_1;
  if(rem_4 && cnt_1)
    cnt_1 = max(0, cnt_1-2*rem_4);

  rem_4 -= (z-cnt_1+1)/2;

  if(rem_4){
    int ee = rem_4 + rem_4/2;
    if(ee <= cnt_2){
      cnt_2 -= ee;
      rem_4 = 0;
    }
    else {
      rem_4 -= (cnt_2*2)/3;
      cnt_2 = 0;
    }
  }

  // cout << cnt_1 << " " << cnt_2 << " " << cnt_3 << " " << cnt_4 << "***\n";

  int xx = rem_4 + n*2;
  int yy = cnt_1 + cnt_2 + cnt_3*2;
  if(xx >= yy) cout << "YES\n";
  else cout << "NO\n";

  return 0;
}

#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef __int64  ll;
#define inf 1000000000
#define mod 1000000007
#define  maxn  105000
#define  lowbit(x) (x&-x)
#define  eps 1e-10
int a[maxn],b[maxn];
int  main(void)
{
	int n,k,i,sum=0,num=0;
	scanf("%d%d",&n,&k);
	sum=n+2*n;
	for(i=1;i<=k;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=k;i++)
	{
		int tmp=a[i]/4;
		num+=tmp;
		a[i]%=4;
		if(a[i]==3)
			a[i]=0,num++;
	}
	if(num<=n)
	{
		sum-=num;
		int sm=n-num;
		for(i=1;i<=k;i++)
		{
			if(sm>0 && a[i]==1)
				sm--,a[i]=0;
		}
		if(sm>0)
		{
			//printf("%d %d\n",sum,sm);
			for(i=1;i<=k;i++)
			{
				while(a[i]>0 && sm>0)
					sm--,a[i]--;
			}
		}
		for(i=1;i<=k;i++)
		{
			sum-=a[i]/2;
			if(a[i]==1)
				sum--;
		}
		if(sum<0)
			printf("NO\n");
		else
			printf("YES\n");
	}
	else
	{
		sum-=n;num-=n;
		sum-=2*num;
		for(i=1;i<=k;i++)
		{
			sum-=(a[i]%4)/2;
			if(a[i]%4==1)
				sum--;
		}
		if(sum<0)
			printf("NO\n");
		else
			printf("YES\n");
	}
	return 0;
}

#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long
#define FILE ""

using namespace std;

const int mod = 1e9 + 7;
const ll inf = 1e18;

int cnt[4];

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    int k2 = 2 * n, k4 = n, k1 = 0;
    for (int i=0;i<k;i++){
        int x;
        cin >> x;
        while (x >= 3){
            if (k4){
                x -= 4;
                k4--;
            } else if (k2){
                x -= 2;
                k2--;
            } else {
               cout << "NO" << endl;
               return 0;
            }
        }
        if (x) cnt[x]++;
    }
    while (cnt[2]){
        if (k2){
            k2--;
            cnt[2]--;
        } else if (k4){
            k4--;
            cnt[2]--;
            k1++;
        } else {
          cnt[2]--;
          cnt[1]+=2;
        }
    }
    if (cnt[1] > k1 + k2 + 2 * k4){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<iostream>
using namespace std;
int main()
{
	int grp,p,m,line,t,twos,fours,twop,onep,r,tot;
//	freopen("airplane.in","r",stdin);
//	freopen("airplane.out","w",stdout);

//	scanf("%d",&t);
//	while(t--)
//	{
		scanf("%d%d",&line,&grp);
		fours=line;
		twos=2*line;
		twop=onep=0;
		for (int i=1;i<=grp;i++)
		{
			scanf("%d",&p);
			r=p/4;
			if (fours-r>=0) fours-=r;
			else
			{
				twos=twos-(r-fours)*2;
				fours=0;
			}
			m=p%4;
			if (m>=2) twop++;
			if (m&1) onep++;
		}
		if (twop==0 && onep==0)
		{
			printf("YES\n");
			//continue;
			return 0;
		}
		while(fours>0)
		{
			fours--;
			if (twop>0)
			{
				twop--;
				if (onep>0) onep--;
				else if (twop>0)
				{
					twop--;
					onep++;
				}
				continue;
			}
			onep-=2;
		}
		tot=onep+twop;
		if(tot<=twos) printf("YES\n");
		else printf("NO\n");
//	}

//	fclose(stdin);
//	fclose(stdout);
	return 0;
}

#include<iostream>
#include <fstream>

using namespace std;

template <typename T>
void QS(T arr[], int l, int r)
{
	int i = l;
	int j = r;
	T middle = arr[(j + i) / 2];
	do
	{
		while (middle<arr[i])i++;
		while (middle>arr[j])j--;
		if (i <= j)
		{
			swap(arr[i], arr[j]);
			i++;
			j--;
		}

	} while (i < j);
		if (i<r)
			QS(arr,i , r);
	if (j>l)
		QS(arr, l, j);
}
bool smol(int &n, int &k)
{
    bool q=false;
	int* n1 = new int [n];
	int ind = n-1;
	for (int i(0);i < n;i++)
		n1[i] = 4;

	int* s = new int[n];
	for (int i(0);i < n;i++)
		s[i] = 4;
	int* l = new int[k];
	for (int i(0);i < k;i++)
	{
		cin >> l[i];
		if(l[i]==1)
		q=true;
		while (l[i] >= 4 && ind >=0)
		{
			l[i] -= 4;
			ind--;

		}

	}

	QS(l, 0, k - 1);
	int k1 = k;

	for (int i(0);i < k1;i++)
	{
		switch (l[i])
		{

		case 4:
		case 3:if (ind >= 0) { ind--;k--;l[i] = 0; }
			   else for (int j(0);j < n && l[i] != 0;j++)
			   {
				   if (s[j] == 4)
				   {
					   s[j] = 0;k--;l[i] = 0;
				   }

			   }
			   break;

		case 2: for (int j(0);j < n && l[i] != 0;j++)
		{
			 if (s[j] >= 2) { s[j] -= 2;l[i] = 0; }
		}
				if (l[i] != 0)
					for (int j(ind);j >=0 && l[i] != 0;j--)
					{
						if (n1[j] > 2 && l[i]==2) { n1[j] -= 3;l[i] = 0; }
						else if (n1[j] >= 1 && !q ) { n1[j] -= 1;l[i] -= 1; }
					}
				if(l[i]==0)k--;
				break;
		case 1:for (int j(0);j < n && l[i] != 0;j++)
		{
			if (s[j] > 1) { s[j] -= 2;k--;l[i] = 0; }
			else if (s[j] == 1) { s[j] -= 1;k--;l[i] = 0; }
		}
			   if (l[i] != 0)
				   for (int j(ind);j != -1 && l[i] != 0;j--)
					   if (n1[j] == 1) { n1[j] -= 1;k--;l[i] = 0; }
					   else if (n1[j] > 1) { n1[j] -= 2;k--;l[i] = 0; }
					   break;

		case 0:k--;break;

		default:
				for (int j(0);j < n && l[i] != 0;j++)
				{
					if (l[i] > 4 && s[j]>0)
					{
						l[i] -= s[j];s[j] = 0;
					}

				}
				if (l[i] <=  4)  i--;

				break;

		}

	}
	delete s;
	delete l;
	delete n1;
	if (k == 0) return true;
	else return false;

}
int main()
{

	int k, n;
	cin >> n >> k;

	(smol(n, k) ? ::cout << "YES" : cout << "NO");

	return 0;
}

/*
    author:  Maksim1744
    created: 22.08.2020 20:52:30
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, k;
    cin >> n >> k;
    vector<int> a(k);
    vector<int> b;
    cin >> a;

    for (int spl = 0; spl <= n; ++spl) {
        int c4 = n, c2 = n * 2;
        c4 -= spl;
        c2 += spl;
        int c1 = spl;
        vector<int> b;
        vector<int> left(4, 0);
        for (auto k : a) {
            int x = k / 4;
            k -= x * 4;
            c4 -= x;
            if (k != 0) {
                left[k]++;
                b.pb(k);
            }
        }
        if (spl == 1) show(c1, c2, c4, left);
        while (c4 < 0) {
            c2 -= 2;
            c4++;
        }
        while (c2 < 0) {
            c2++;
            c1 -= 2;
        }
        if (c1 < 0 || c2 < 0 || c4 < 0) {
            continue;
        }
        int u = min(c4, left[3]);
        left[3] -= u;
        c4 -= u;
        if (c4 == 0) {
            while (left[3] != 0) {
                if (c2 != 0) {
                    --c2;
                    --c1;
                } else {
                    c1 -= 3;
                }
                --left[3];
            }
            while (c2 < 0) {
                c2++;
                c1 -= 2;
            }
            while (c1 < 0) {
                c1++;
                c2--;
            }
            if (c1 < 0 || c2 < 0) continue;
            while (left[2] != 0) {
                if (c2 != 0) {
                    --c2;
                } else {
                    c1 -= 2;
                }
                --left[2];
            }
            if (c1 < 0 || c2 < 0) continue;
            while (left[1] != 0) {
                if (c2 != 0) {
                    --c2;
                } else {
                    --c1;
                }
                --left[1];
            }
            if (c1 < 0 || c2 < 0) continue;
        } else {
            while (left[2] != 0) {
                if (c4 != 0) {
                    --c4;
                } else if (c2 != 0) {
                    --c2;
                } else {
                    c1 -= 2;
                }
                --left[2];
            }
            if (c1 < 0 || c2 < 0 || c4 < 0) continue;
            while (left[1] != 0) {
                if (c4 != 0) {
                    --c4;
                } else if (c2 != 0) {
                    --c2;
                } else {
                    --c1;
                }
                --left[1];
            }
            if (c1 < 0 || c2 < 0 || c4 < 0) continue;
        }
        cout << "YES\n";
        return 0;
    }
    cout << "NO\n";

    // int c4 = n, c2 = n * 2;
    // for (auto cnt : a) {
    //     int x = cnt / 4 * 4;
    //     c4 -= x / 4;
    //     cnt -= x;
    //     if (cnt == 0) continue;
    //     if (cnt == 3) {
    //         c4--;
    //         // continue;
    //         // b.pb(1);
    //         // b.pb(2);
    //         continue;
    //     }
    //     b.pb(cnt);
    // }

    // while (c4 < 0) {
    //     c4++;
    //     c2 -= 2;
    // }
    // if (c2 < 0) {
    //     cout << "NO\n";
    //     return 0;
    // }

    // int left1 = 0, left2 = 0;
    // for (auto u : b) {
    //     if (u == 1) ++left1;
    //     else if (u == 2) ++left2;
    //     else assert(false);
    // }
    // show(left1, left2, c2);
    // int mn = min({left1, left2, c4});
    // c4 -= mn;
    // left1 -= mn;
    // left2 -= mn;
    // show(left1, left2, c4, c2);
    // if (left1 == 0) {
    //     int left_cnt = c4 + c2;
    //     if (left2 > left_cnt) {
    //         cout << "NO\n";
    //     } else {
    //         cout << "YES\n";
    //     }
    //     return 0;
    // } else if (left2 == 0) {
    //     int left_cnt = c4 * 2 + c2;
    //     if (left1 > left_cnt) {
    //         cout << "NO\n";
    //     } else {
    //         cout << "YES\n";
    //     }
    //     return 0;
    // } else {
    //     assert(c4 == 0);
    //     int left_cnt = c2;
    //     if (left1 + left2 > left_cnt) {
    //         cout << "NO\n";
    //     } else {
    //         cout << "YES\n";
    //     }
    //     return 0;
    // }

    return 0;
}

#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cmath>
#include <ctime>
#include <algorithm>

using namespace std;
const int INF = int(2e9);

int main()
{
#ifdef MY_DEBUG
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif

  int n = 0, k = 0;
  cin >> n >> k;
  vector<int> a(k);
  for(int i = 0; i < k; i++)
    cin >> a[i];

  int x = n, y = n, z = n;
  for(int i = 0; i < k; i++)
  {
    int t = a[i] / 4;
    if(t <= z)
    {
      z -= t;
      a[i] -= 4 * t;
    }
    else
    {
      a[i] -= 4 * z;
      z = 0;
    }
  }

  for(int i = 0; i < k; i++)
  {
    int t = a[i] / 2;
    if(t <= x)
    {
      x -= t;
      a[i] -= 2 * t;
    }
    else
    {
      a[i] -= 2 * x;
      x = 0;
    }
  }

  for(int i = 0; i < k; i++)
  {
    int t = a[i] / 2;
    if(t <= y)
    {
      y -= t;
      a[i] -= 2 * t;
    }
    else
    {
      a[i] -= 2 * y;
      y = 0;
    }
  }

  int s1 = 0, s2 = 0, s3 = 0;
  for(int i = 0; i < k; i++)
  {
    if(a[i] == 1)
      s1++;
    else if(a[i] == 2)
      s2++;
    else if(a[i] == 3)
      s3++;
  }

  if(s2 || s3)
  {
    if(s1 >= s2)
    {
      z-= s2;
      s1 -=s2;
      z -= 2*s1;
      if(z >= 0)
      {
        cout << "YES";
      }
      else
      {
        cout << "NO";
      }
      return 0;
    }
    else
    {
      z -= s1;
      z -= 2 * (s2 / 3);
      z -= (s2 % 3);
      if(z >= 0)
      {
        cout << "YES";
      }
      else
      {
        cout << "NO";
      }
      return 0;
    }
  }
  else
  {
    if(2*z + x + y >= s1)
    {
      cout << "YES";
    }
    else
    {
      cout << "NO";
    }
  }

  return 0;
}

#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("NO"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll LLINF = LLONG_MAX;
const int INF = INT_MAX;
const int MAXN = 1e4 + 10;
const int mod = 1e9 + 7;

int n, k;
int a[MAXN];

int main()
{
    scanf("%d%d", &n, &k);
    int row4 = n;
    int row2 = 2 * n;
    int extrarow4 = 0;
    for (int i = 0; i < k; i++)
    {
        scanf("%d", &a[i]);
        while (a[i] >= 4)
            if (row4) row4--, a[i] -= 4;
            else { if (row2 >= 2) { row2 -= 2, a[i] -= 4; } else EXIT_NO_SUCCESS; }
    }
    for (int i = 0; i < k; i++)
    {
        if (a[i] == 3)
        {
            if (row4) row4--;
            else { if (row2 >= 2) { row2 -= 2; } else { if (extrarow4 >= 3) extrarow4 -= 3; else EXIT_NO_SUCCESS } }
        }
        else if (a[i] == 2)
        {
            if (row2) row2--;
            else { if (row4) { row4--, extrarow4++; } else { if (extrarow4 >= 2) extrarow4 -= 2; else EXIT_NO_SUCCESS; } }
        }
        else if (a[i] == 1)
        {
            if (extrarow4) extrarow4--;
            else if (row4) row4--, row2++;
            else if (row2) row2--;
            else EXIT_NO_SUCCESS;
        }
    }

    puts("YES");

    return 0;
}

/*input
2 7
2 2 2 2 2 2 2
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	int k4 = n;
	int k2 = n * 2;
	int k1 = 0;
	int a3 = 0;
	int a2 = 0;
	int a1 = 0;
	while (k--)
	{
		int a;
		cin >> a;
		while (a >= 4)
		{
			if (k4 > 0)
			{
				k4--;
				a -= 4;
				continue;
			}
			if (k2 > 0)
			{
				k2--;
				a -= 2;
				continue;
			}
			cout << "NO\n";
			return 0;
		}
		if (a == 3)
			a3++;
		if (a == 2)
			a2++;
		if (a == 1)
			a1++;
	}
	while (a3 > 0)
	{
		if (k4 > 0)
		{
			k4--;
			a3--;
			continue;
		}
		if (k2 > 1)
		{
			k2 -= 2;
			a3--;
			continue;
		}
		cout << "NO\n";
		return 0;
	}
	while (a2 > 0)
	{
		if (k4 > 0)
		{
			k4--;
			k1++;
			a2--;
			continue;
		}
		if (k2 > 0)
		{
			k2--;
			a2--;
			continue;
		}
		if (k1 > 1)
		{
			k1 -= 2;
			a2--;
			continue;
		}
		cout << "NO\n";
		return 0;
	}
	while (a1 > 0)
	{
		if (k4 > 0)
		{
			k4--;
			k2++;
			a1--;
			continue;
		}
		if (k2 > 0)
		{
			k2--;
			a1--;
			continue;
		}
		if (k1 > 0)
		{
			k1--;
			a1--;
			continue;
		}
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
}

#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back

using namespace std;

int arr[10000];

main()
{

    int n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int p;
        cin>>arr[i];
    }
    int m = n;
    for(int i=0;i<k;i++){
        int val = arr[i]/4;
        if(val<=m){
            m-=val;
            val=0;
        }
        else{
            val-=m;
            m=0;
        }
        arr[i] = arr[i]%4+(val*4);
    }
    for(int i=0;i<k;i++){
        if(arr[i]==3 && m){
            m--;
            arr[i]=0;
        }
    }
    int rem1 = m;
    n = 2*n+m;

    for(int i=0;i<k;i++){
        int val = arr[i]/2;
        if(val<=n){
            n-=val;
            val=0;
        }
        else{
            val-=n;
            n=0;
        }
        arr[i] = arr[i]%2+(val*2);
    }
    n+=rem1;
    int cnt=0;
    for(int i=0;i<k;i++){
        cnt+=arr[i];
    }
    if(cnt<=n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo LLONG_MAX

void solve(){
   ll n,k;
   cin>>n>>k;
   ll a[k];
   fo(i,k){
       cin>>a[i];
   }
   ll val[5]={0},cnt[5]={0};
   val[2]=(n*2LL);
   val[4]=n;
   fo(i,k){
       ll x=a[i];
       while(x >= 3)
    			if(val[4] > 0)
    				x -= 4, val[4]--;
    			else if(val[2] > 0)
    				x -= 2, val[2]--;
    			else{
    				cout << "NO" << '\n';
    				return;
    			}
    		if(x > 0)
    			cnt[x]++;
    }
	while(cnt[2])
		if(val[2] > 0)
			cnt[2]--,val[2]--;
		else if(val[4] > 0)
			cnt[2]--, val[4]--, val[1]++;
		else
            cnt[2]--, cnt[1] += 2;
	if(cnt[1] > val[1] + val[2] + val[4] * 2)
		 cout << "NO" << '\n';
		 else
	cout << "YES" << '\n';
}

int main(){
    Boost();
    #ifndef ONLINE_JUDGE
    kill
    #endif
    ll T = 1;
   // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

#include <cstdio>
#include <algorithm>

using namespace std;

class airplane_rows
{
    size_t a, two_seats, four_seats, two_seats_for_one, u1, u2, u3;

    bool seat3()
    {
        if ( u3 > 0 && four_seats > 0 )
            a = min( u3, four_seats ), four_seats -= a, u3 -= a;

        if ( u3 > 0 && two_seats > 0 )
        {
            a = min( u3, two_seats );

            if ( a == u3 )
                two_seats_for_one += u3;
            else
                u1 += two_seats;

            two_seats -= a, u3 -= a;

        }

        if ( u3 > 0 && two_seats_for_one > 0 )
            a = min( u3, two_seats_for_one ), u2 += a, two_seats_for_one -= a, u3 -= a;

        return u3 == 0;
    }

    bool seat2()
    {
        if ( u2 > 0 && four_seats > 0 )
            a = min( u2, four_seats ), two_seats_for_one += a, four_seats -= a, u2 -= a;

        if ( u2 > 0 && two_seats > 0 )
            a = min( u2, two_seats ), two_seats -= a, u2 -= a;

        if ( u2 > 0 && two_seats_for_one > 0 )
            a = min( u2, two_seats_for_one ), u1 += a, two_seats_for_one -= a, u2 -= a;

        return u2 == 0;
    }

    bool seat1()
    {
        if ( u1 > 0 && four_seats > 0 )
            a = min( u1, 2 * four_seats ), u1 -= a;

        if ( u1 > 0 && two_seats > 0 )
            a = min( u1, two_seats ), u1 -= a;

        if ( u1 > 0 && two_seats_for_one > 0 )
            a = min( u1, two_seats_for_one ), u1 -= a;

        return u1 == 0;
    }

    void read_group()
    {
        scanf( "%u", &a );

        while( a >= 4 && four_seats > 0 ) a -= 4, four_seats--;

        while( a >= 2 &&  two_seats > 0 ) a -= 2,  two_seats--;

        switch( a )
        {
        case 1: u1++; break;
        case 2: u2++; break;
        case 3: u3++; break;
        default:      break;
        }
    }

public:

    airplane_rows() : two_seats( 0 ), four_seats( 0 ), two_seats_for_one( 0 ), u1( 0 ), u2( 0 ), u3( 0 )
    {
        size_t k, n; scanf( "%u %u", &n, &k ), four_seats = n, two_seats = 2 * n;

        for( size_t i = 0; i < k; i++ )
            read_group();
    }

    const char *solution()
    {
        return ( seat3() && seat2() && seat1() ) ? "YES" : "NO";
    }
};

int main()
{
    airplane_rows problem;

    printf( "%s", problem.solution() );
}

#include <iostream>
#include <algorithm>

using namespace std;

int main() {

	int n,k,x,i;
	cin >> n >> k;

	int groups=0,lp=0,fours=0,loners=0,done;

	for (i=0;i<k;i++) {
		cin >> x;
		fours+=x/4;
		x%=4;
		lp+=x/2;
		loners+=x%2;
	}
	groups=min(fours,n);
	fours-=groups;

	done=groups;
	groups=min(groups+min(lp,loners),n);
	done=groups-done;
	lp-=done;
	loners-=done;

	done=groups;
	groups=min(groups+lp,n);
	done=groups-done;
	lp-=done;
	lp-=done/2;

	done=groups;
	groups=min(groups+loners/2,n);
	done=groups-done;
	loners-=done*2;

	done=groups;
	groups=min(groups+loners,n);
	done=groups-done;
	loners-=done;

	if (fours*2+lp+loners<=2*n) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//这应该是1900最简单的题了，4个位置的最棘手，那么先处理4个位置的，如果还有剩余，可以把他看到2个和1个的，先处理1个的，如果还有剩余，那么只能看成2个的
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 4e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
/*ll gcd(ll a, ll b)//最大公约数
{
r	eturn b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//快速幂
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
		k >>= 1;
		a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//组合数的计算
{
ll ans = 1;
for (ll i = 1;i <= m;i++)
ans = (ans*(n - m + i) / i) ;
return ans;
}

bool is_prime(ll x)//素数判断
{
if (x == 2 || x == 3) return true;
if (x % 6 != 1 && x % 6 != 5) return false;
ll temp = sqrt(1.0*x);
for (ll i = 5;i <= temp;i += 6)
if (x%i == 0 || x % (i + 2) == 0) return false;
return true;
}
int prime[maxm], pnum = 0;//素数表，pnum是索引
bool p[maxm] = { 0 };//如果被筛掉，就为true
void Find_Prime()//更快的筛选法，遇到一个素数，就把它的倍数全部筛掉
{
for (int i = 2;i < maxm;i++)
{
if (p[i] == false)//不用一个数一个数的判断素数了
{
prime[pnum++] = i;
for (int j = i + i;j < maxm;j += i)//筛掉素数的倍数
p[j] = true;
}
}
}

void Exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) x = 1, y = 0;
else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x是a在mod b下的逆元
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///M为除数乘积
}
for(int i=0; i<n; i++)
{
t=M/m[i];///除了mi以外的n-1个整数乘积
Exgcd(t,m[i],x,y);///求逆元，由扩展欧几里得转换成t*ti+m[i]*y=1来求ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}
struct Edge
{
int to, next;
}edge[maxn<<1];
int cnt, head[maxn];*/

int n, k;
int a[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> k;
	int p = n, q = 2 * n;
	for (int i = 1;i <= k;i++)
	{
		cin >> a[i];
		while (a[i] >= 4 && p)
		{
			a[i] -= 4;
			p--;
		}
	}
	if (p == -1) p = 0;
	q += p;
	for (int i = 1;i <= k&&p;i++)
	{
		if (a[i] & 1)
		{
			a[i]--;
			p--;
		}
	}
	q += (p / 2);
	for (int i = 1;i <= k;i++)
		q -= ((a[i]+1) / 2);
	if (q >= 0) cout << "YES";
	else cout << "NO";
	return ~~(0 - 0);
}

#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define MN 105
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[MN],n,m,sum1,sum2;

int main()
{
    int i,j;
    n=read(); m=read();
    for (i=1;i<=m;++i) a[i]=read();
    for (i=1,j=1;i<=n;++i)
    {
        while (a[j]<4&&j<=m) ++j;
        if (j>m) break; a[j]-=4;
    }
    if (i<=n) sum1+=n-i+1,sum2+=n-i+1;
    sum1+=n*2;
    for (i=1,j=1;i<=sum1;++i)
    {
        while (a[j]<2&&j<=m) ++j;
        if (j>m) break; a[j]-=2;
    }
    if (i<=sum1) sum2+=sum1-i+1;
    for (i=1,j=1;i<=sum2;++i)
    {
        while (a[j]<1&&j<=m) ++j;
        if (j>m) break; a[j]-=1;
    }
    for (i=1;i<=m;++i) if (a[i]) return 0*printf("NO");
    printf("YES");
}

/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 100005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k; cin>>n>>k;
    int res=0, one=0, two=0, three=0;
    for(int i=1; i<=k; i++){
        int a; cin>>a;
        res += a/4;
        if(a%4==1) one++;
        else if(a%4==2) two++;
        else if(a%4==3) three++;
    }
    if(res>n){
        res-=n;
        res*=2;
        res+=one;
        res+=two;
        res+=(three*2);
        n *= 2;
        if(res<=n) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        return 0;
    }
    else{
        int temp = n-res;
        if(temp<=three){
            three-=temp;
            res=one;
            res+=two;
            res+=(three*2);
            n *= 2;
            if(res<=n) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            return 0;
        }
        else{
            temp -= three;
            if(two==0){
                n+=temp;
                n *= 2;
                res=one;
                if(res<=n) cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
                return 0;
            }
            if(one==0){
                n*=2;
                n+=temp;
                res=two;
                if(res<=n) cout<<"YES"<<endl;
                else{
                    res-=n;
                    if(res*2<=temp) cout<<"YES"<<endl;
                    else cout<<"NO"<<endl;
                }
                return 0;
            }
            int mn = min(temp, min(one, two));
            temp-=mn;
            one-=mn;
            two-=mn;
            if(temp==0){
                res = one+two;
                n*=2;
                if(res<=n) cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
                return 0;
            }
            else if(one==0){
                n*=2;
                n+=temp;
                res=two;
                if(res<=n) cout<<"YES"<<endl;
                else{
                    res-=n;
                    if(res*2<=temp) cout<<"YES"<<endl;
                    else cout<<"NO"<<endl;
                }
                return 0;
            }
            else if(two==0){
                n*=2;
                n+=temp*2;
                res=one;
                if(res<=n) cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <csignal>
#include <bitset>
#include <functional>
#include <ctime>
#include <tuple>
#include <cassert>
#include <cstring>
#include <list>
#include <array>
#include <iterator>
#include <type_traits>
#include <climits>

//#pragma optimize("O2")

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

using namespace std;

//#define int long long
//#define double long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define rep(x, a, n, j) for(int x = a; x < n; x += j)
#define fi first
#define se second

const int MAXN = 105;
const int INF = INT_MAX; //1е9
const int MOD = 1000000007;

int have[5], c[5];

signed main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	int n, k;
	cin >> n >> k;
	have[2] = 2 * n, have[4] = n;

	for (int i = 0; i < k; ++i) {
		int x;
		cin >> x;
		while (x >= 3) {
			if (have[4] > 0)
				have[4]--, x -= 4;
			else if (have[2] > 0)
				have[2]--, x -= 2;
			else
				return cout << "NO", 0;
		}
		if (x > 0)
			c[x]++;
	}

	while (c[2]) {
		if (have[2] > 0)
			have[2]--, c[2]--;
		else if (have[4] > 0)
			c[2]--, have[4]--, have[1]++;
		else
			c[2]--, c[1] += 2;
		if (c[2] > have[1] + have[2] + have[4] * 2)
			return cout << "NO", 0;
	}
	while (c[1]) {
		if (have[1] > 0)
			have[1]--, c[1]--;
		else if (have[2] > 0)
			have[2]--, c[1]--;
		else if (have[4] > 0)
			have[4]--, have[2]++, c[1]--;
		else
			return cout << "NO", 0;
	}
	cout << "YES";
	return 0;
}

#include<stdio.h>
#include<string.h>
const int MAXN=1005;
int main()
{
	int n,m,i,j;
	while(~scanf("%d%d",&n,&m))
	{
		int a[MAXN]={0},cnta=n,cntb=n*2,cntc=0;
		for(i=1;i<=m;i++)
		scanf("%d",&a[i]);
		for(i=1;i<=m;i++){
			cnta-=a[i]/4;
			a[i]%=4;
			cnta-=a[i]/3;
			a[i]%=3;
		}
		int s1=0,s2=0;
		for(i=1;i<=m;i++)
		{
			if(a[i]==1)
			s1++;
			else if(a[i]==2)
			s2++;
		}
		if(cnta<0)
		{
			cntb+=cnta*2;
			cntb-=s2+s1;
			if(cntb<0)
			printf("NO\n");
			else
			printf("YES\n");
		}
		else
		{
		//	printf("%d\n",cnta);
			cntb+=cnta;
			cntc=cnta;
			cntb-=s2;
			if(cntb<0)
			cntc=cntc+cntb*2-s1;
			if(cntb>=0)
			cntc=cntc+cntb-s1;
		//	printf("%d   %d\n",s1,cntc);
			if(cntc<0)
			printf("NO\n");
			else
			printf("YES\n");
		}
	}
}

#include<cstdio>
#include<iostream>
using namespace std;
int n,k,ans,x;
int s2,s4;
int main()
{
	scanf("%d%d",&n,&k);
	s2=2*n;
	s4=n;
	for (int i=1;i<=k;i++)
	{
		scanf("%d",&x);
		//if (x&1) x++;
		//-cout<<x<<endl;
		if (s4>=x/4) s4-=(x/4),x=x%4;
		else x-=4*s4,s4=0;
		s2-=x/2;
		if (x%2==1)
			ans--;
		//cout<<s2<<" "<<s4<<endl;
		if (s2<0)
			if (s4<=0)
			{
				ans-=2;s2=0;
				//else{printf("NO");return 0;}
			}
			else
			{
				s4--;
				s2=0;
				ans++;
			}
	}
//	cout<<ans<<endl;
	if (s4>=0) ans+=s4*2;
	if (s2>=0) ans+=s2;
//	cout<<s2<<" "<<ans<<endl;
	if (ans>=0)
		printf("YES");
	else printf("NO");
}

#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL INF = 0x3f3f3f3f;
const int MAX_N = 1e5 + 10;
const LL mod = 1e9 + 7;
const double PI=acos(-1);
int num[MAX_N];
int main()
{
    int a, b, d, n, k, x;
    scanf("%d%d", &n, &k);
    a = 0;
    b = n * 2;
    d = n;
    bool flag = true;
    for(int i = 1; i <= k; ++i){
        scanf("%d", &x);
        while(x >= 4){
            if(b == 0 && d == 0)    break;
            if(d){  d--;    x -= 4;}
            else if(b){ b --; x -= 2;}
        }
        if(x >= 4)  flag = false;
        num[i] = x;
    }
    for(int i = 1; i <= k; ++i){
        if(num[i] == 3){
            if(b && a) b--, a--;
            else if(d)   d--;
            else if(a >= 3)  a -= 3;
            else if(b >= 2) b -= 2;
            else flag = false;
        }
        else if(num[i] == 2){
            if(b)   b--;
            else if(d)  d--, a++;
            else if(a >= 2) a-= 2;
            else flag = false;
        }
        else if(num[i] == 1){
            if(a)   a--;
            else if(d)  d--, b++;
            else if(b)  b--;
            else flag = false;
        }
       // printf("%d %d %d\n", a, b, d);
    }
   // printf("%d %d %d", a, b, d);
    if(flag)    puts("YES");
    else puts("NO");
    return 0;
}

#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long
#define FILE ""

using namespace std;

const int mod = 1e9 + 7;
const ll inf = 1e18;

int cnt[4];

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    int k2 = 2 * n, k4 = n, k1 = 0;
    for (int i=0;i<k;i++){
        int x;
        cin >> x;
        while (x >= 3){
            if (k4){
                x -= 4;
                k4--;
            } else if (k2){
                x -= 2;
                k2--;
            } else {
               cout << "NO" << endl;
               return 0;
            }
        }
        if (x) cnt[x]++;
    }
    while (cnt[2]){
        if (k2){
            k2--;
            cnt[2]--;
        } else if (k4){
            k4--;
            cnt[2]--;
            k1++;
        } else {
          cnt[2]--;
          cnt[1]+=2;
        }
    }
    if (cnt[1] > k1 + k2 + 2 * k4){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define ll long long
#define ull unsigned long long
#define mem(a,x) memset((a),(x),sizeof ((a)))//x只能是0或-1或false或true
#define debug(x) cout<<"X: "<<(x)<<endl
#define de cout<<"************"<<endl
#define lowbit(x) ((x)&(-x))
#define lson rt<<1
#define rson rt<<1|1
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/(__gcd(a,b))
#define inf 0x3f3f3f3f//1e9+6e7
#define eps 1e-8
#define mod 1e9+7
#define N 1000010
const double pi=acos(-1.0);
using namespace std;
int n,k,t[10007],tot;
bool ac(){
    int a=n,b=n*2,c=0;
    for(int i=1;i<=k&&a;i++){
        tot-=t[i];
        if(t[i]/4>a){
            t[i]-=a*4;a=0;
        }
        else{
            a-=t[i]/4;t[i]%=4;
        }
        tot+=t[i];
        if(tot==0)return true;
    }
    for(int i=1;i<=k&&b;i++){
        tot-=t[i];
        if(t[i]/2>b){
            t[i]-=b*2;b=0;
        }
        else{
            b-=t[i]/2;t[i]%=2;
        }
        tot+=t[i];
        if(tot==0)return true;
    }

    for(int i=1;i<=k&&a;i++){
        tot-=t[i];
        if(t[i]/2>a){
            t[i]-=a*2;c+=a;a=0;
        }
        else{
            a-=t[i]/2;c+=t[i]/2;t[i]%=2;
        }
        tot+=t[i];
        if(tot==0)return true;
    }
    return tot<=a*2+b+c;
}
int main(){
    scanf("%d%d",&n,&k);
    tot=0;
    for(int i=1;i<=k;i++){
        scanf("%d",&t[i]);tot+=t[i];
    }
    printf(ac()?"YES\n":"NO\n");
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;

int n, k, v[maxn], ans;

bool solve()
{
    int num1=0, num2=n*2, num4=n;
    for (int i=0; i<k; i++){
        if (num4>=v[i]/4) num4-=v[i]/4;
        else {
            int left = v[i]/4 - num4;
            num4 = 0;
            if (num2>=left*2) num2-=left*2;
            else return false;
        }
        v[i] %= 4;
    }

    for (int i=0; i<k; i++){ //cout<<num4<<" "<<num2<<" "<<num1<<" "<<v[i]<<endl;
        if (v[i] == 1){
            if (num1>0) num1--;
            else if (num4>0){
                num4--; num2++;
            } else if (num2>0) num2--;
            else return false;
        } else if (v[i]==2){
            if (num2>0) num2--;
            else if (num4>0){
                num4--;
                num1++;
            } else if (num1>=2) num1-=2;
            else return false;
        } else if (v[i]==3){
            if (num1>0&&num2>0){
                num1--; num2--;
            } else if (num1>=3) num1-=3;
            else if (num4>0) num4--;
            else if (num2>=2) num2-=2;
            else return false;
        }
    }

    return true;
}

int main()
{
    cin>>n>>k;
    for (int i=0; i<k; i++){
        cin>>v[i];
        ans += v[i];
    }

    if (solve()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<string>
#include<fstream>
#include<vector>
#include<stack>
#include <map>
#include <iomanip>

#define bug cout << "**********" << endl
#define show(x, y) cout<<"["<<x<<","<<y<<"] "
#define LOCAL = 1;
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353;
const int Max = 1e6 + 10;
const int Max2 = 1e3 + 10;

int n, k;
int a[Max];

int main()
{
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    while (scanf("%d%d", &n, &k) != EOF)
    {
        int sum2 = 2 * n, sum4 = n; //记录当前剩余的位置数
        int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
        for (int i = 1; i <= k; i++)
        {
            scanf("%d", a + i);
            x4 += a[i] / 4;
            int res = a[i] % 4;
            if (res == 1)
                x1++;
            else if (res == 2)
                x2++;
            else if(res == 3)
                x3++;
        }
        while (sum4 > 0 && x4 > 0)      //四人分配四人座
        {
            sum4--;x4--;
        }
        while (sum4 > 0 && x3 > 0)       //三人分配四人座
        {
            sum4--; x3--;
        }
        while (sum4 > 0 && x2 > 0)       //双人和个人一起用一个四人位
        {
            sum4--;x2--;x1--;
        }
        while (sum4 > 0 && x1 > 0)      //一个人独占四人座，同时产生一个两人座
        {
            sum4--;x1--;sum2++;
        }
        /**********************************/
        while(sum2 > 1 && x4 > 0)       //四人占两个双人位
        {
            sum2 -= 2 ;x4--;
        }
        while(sum2 > 1 && x3 > 0)       //三人占用两个双人位
        {
            sum2 -= 2;x3--;
        }
        while(sum2 > 0 && x2 > 0)       //两个人占用一个双人位
        {
            sum2 --;x2--;
        }
        while(sum2 > 0 && x1  > 0)      //一人占用一个单人位
        {
            sum2--;x1--;
        }
        if(x1 <= 0 && x2 <= 0 && x3 <= 0 && x4 <= 0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[110];
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&a[i]);
	}
	int tmp=0;
	for(int i=1;i<=k;i++)
	{
		while(a[i]>=8)
		{
			a[i]-=8;
			n--;
		}
		if(a[i]%2==0)
		{
			tmp+=a[i];
		}
		else
		{
			tmp+=a[i]+1;
		}
	}
	if(n*8>=tmp)
	printf("YES");
	else
	printf("NO");
}

#include<iostream>
#include <fstream>

using namespace std;

template <typename T>
void QS(T arr[], int l, int r)
{
	int i = l;
	int j = r;
	T middle = arr[(j + i) / 2];
	do
	{
		while (middle<arr[i])i++;
		while (middle>arr[j])j--;
		if (i <= j)
		{
			swap(arr[i], arr[j]);
			i++;
			j--;
		}

	} while (i < j);
		if (i<r)
			QS(arr,i , r);
	if (j>l)
		QS(arr, l, j);
}
bool smol(int &n, int &k)
{
	int* n1 = new int [n];
	int ind = n-1;
	for (int i(0);i < n;i++)
		n1[i] = 4;
	int* s = new int[n];
	for (int i(0);i < n;i++)
		s[i] = 4;
	int* l = new int[k];
	for (int i(0);i < k;i++)
	{
		cin >> l[i];
		while (l[i] >= 4 && ind >=0)
		{
			l[i] -= 4;
			ind--;

		}

	}
	QS(l, 0, k - 1);
	int k1 = k;
	for (int i(0);i < k1;i++)
	{
		switch (l[i])
		{
		default:

		case 3:if (ind=!-1) { ind--;k--;l[i] = 0; }
			   else for (int j(0);j < n && l[i] != 0;j++)
			   {
				   if (s[j] == 4)
				   {
					   s[j] -= 4;k--;l[i] = 0;
				   }

			   }
			   break;

		case 2: for (int j(0);j < n && l[i] != 0;j++)

			if (s[j] >= 2) { s[j] -= 2;k--;l[i] = 0; }
				if (l[i] != 0)
					for (int j(ind);j != -1 && l[i] != 0;j--)
						if (n1[j] >= 2) { n1[j] -= 3;k--;l[i] = 0; }
				break;
		case 1:for (int j(0);j < n && l[i] != 0;j++)

			if (s[j] >= 2) { s[j] -= 2;k--;l[i] = 0; }
			   if (l[i] != 0)
				   for (int j(ind);j != -1 && l[i] != 0;j--)
					   if (n1[j] >= 1) { n1[j] -= 1;k--;l[i] = 0;}
			   break;

		case 0:k--;break;

		}

	}
	delete s;
	delete l;
	delete n1;
	if (k == 0) return true;
	else return false;

}
int main()
{
	int k, n;
	cin >> n >> k;

	(smol(n, k) ? ::cout << "YES" : cout << "NO");

	return 0;
}

#include <iostream>
using namespace std;
int main() {printf("YES");return 0;}

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int n, k, a[105], c1, c2, c4, curr;

int main() {
	scanf("%d %d", &n, &k);
	c2 = n * 2, c4 = n;
	for (int i = 0; i < k; i++) {
		scanf("%d", a + i);
		int tmp4 = min(c4, a[i] / 4);
		c4 -= tmp4;
		a[i] -= tmp4 * 4;
		int tmp2 = min(c2, a[i] / 2);
		c2 -= tmp2;
		a[i] -= tmp2 * 2;
		int tmp1 = min(c1, a[i]);
		c1 -= tmp1;
		a[i] -= tmp1;
		if (a[i] > 0) {
			assert(c1 == 0);
			if (c4 == 0 && c2 == 0) {
				printf("No\n");
				return 0;
			}
			assert(a[i] >= 1 || a[i] <= 3);
			if (a[i] == 3) {
				assert(c2 == 0);
				c4--;
				continue;
			} else if (a[i] == 2) {
				assert(c2 == 0);
				c4--;
				c1++;
				continue;
			}
			if (c4 > 0) c4--, c2++;
			else if (c2 > 0) c2--;
		}
	}
	printf("Yes\n");
#ifdef LOCAL_MSVC_DEBUG
	system("pause");
#endif
	return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#define ll long long
const int maxn=3e5+10;
const int inf=0x3f3f3f3f;
using namespace std;

ll a[111];
int main()
{
   ll n,k;  cin>>n>>k;
   ll s=0,cc=0;
   ll hh=0,pp=0,qq=0;
   for(int i=1;i<=k;i++)
   {
       cin>>a[i];
       s+=a[i];
       if(a[i]%2) cc++;
       if(a[i]%8==2) hh++;
       if(a[i]%8==6)  pp++;
       if(a[i]%8==4)  qq++;
   }
   s+=cc;
   hh-=(s/8*2);
   hh-=pp;
   hh-=qq*2;
   hh=(hh-1)/3*2;
   if(hh<0)  hh=0;
   if(s+hh<=8*n) puts("YES");
   else  puts("NO");
return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define LL long long
#define INF (1<<30)
using namespace std;

int g[100100],sum;
int main(){
	int n,k;cin>>n>>k;
	int a=n*2,b=n;
	for(int i=1;i<=k;i++)
		scanf("%d",&g[i]),sum+=g[i];
	if(sum>n*8){printf("NO");return 0;}
	for(int i=1;i<=k;i++)
		while(g[i]>2&&b)g[i]-=4,b--;
	for(int i=1;i<=k;i++)
		while(g[i]>0&&a)g[i]-=2,a--;
	int c=b,d=b;
	for(int i=1;i<=k;i++)
		while(g[i]>0&&c)g[i]-=2,c--;
	for(int i=1;i<=k;i++)
		while(g[i]>0)g[i]--,d--;
	if(d<0)printf("NO");
	else printf("YES");
}

#include <iostream>
#include <vector>

using namespace std;

bool combPossible(int n, int k, vector<int> group){
    int totalNoOfSeats=n*8;
    int seatsNeeded=0;
    int groupsOfFour=0;
    for(int i=0;i<group.size();i++){
        while(group[i]>=4){
            seatsNeeded+=4;
            group[i]-=4;
            groupsOfFour++;
        }
        if(groupsOfFour>=n){
            break;

        }
    }
    for(int i=0;i<group.size();i++){
        if(group[i]%2==0)
            seatsNeeded+=group[i];
        else
            seatsNeeded+=group[i]+1;

        if(seatsNeeded<=totalNoOfSeats)
            return true;
    }
    return false;

}

int main(){
    int n,k,solInGrp;;
    vector<int> group;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>solInGrp;
        group.push_back(solInGrp);
    }
    if(combPossible(n,k,group))
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, k, flag;
int a[105], sum[105];
int main()
{
	flag = 0;
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= k; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] % 2 == 1) a[i]++;
		sum[i] = sum[i - 1] + a[i];
	}
	sort(a + 1, a + 1 + k);
	int p = n;
	if(n * 8 < sum[k]) flag = 1;
	for(int i = k; i >= 1; i--)
	{
		if(a[i] >= 4) {
			int t = a[i] / 4;
			if(t > p) {
				a[i] = a[i] - p * 4;
				p = 0;
				break;
			}
			else {
				a[i] = a[i] - t * 4;
				p -= t;
			}
		}
	}
	for(int i = 1; i <= k; i++) a[i] += a[i - 1];
	if(p != 0) {
		int zong = n * 8;
		zong = zong - (n - p) * 4;
		zong = zong - p * 2;
		if(zong < a[k]) flag = 1;
	}
	if(flag == 1) printf("NO\n");
	else printf("YES\n");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;

int main()
{
    int n, k; cin>>n>>k;
    ll cur = 0;
    for (int i=0; i<k; i++){

        int y = cur%8;
        if (y!=1&&y!=5&&y!=7) cur++;

        int x; cin>>x;
        cur += (ll) x;

    }

    if (cur > 8*n) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int n, k, a[105] = {0};

bool cmp(int a, int b) {
    return a > b;
}

int sum() {
    int s = 0;
    for(int i = 0; i < k; i++)
        s += a[i];
    return s;
}

bool Ju() {
    int f = n, t = 2*n;
    for(int i = 0; i < k; i++) {
        int q = a[i] / 4;
        a[i] = a[i] % 4;
        if(f >= q) {
            f -= q;
        } else {
            q -= f;
            f = 0;
            a[i] += 4*q;
        }
    }
    for(int i = 0; i < k; i++) {
        int q = a[i] / 2;
        a[i] = a[i] % 2;
        if(t >= q) {
            t -= q;
        } else {
            q -= t;
            t = 0;
            a[i] += 2*q;
        }
    }
    if(sum() == 0)
        return true;
    else {
        if(f == 0 && t == 0)
            return false;
        else if(f > 0 && t == 0) {
            if(sum() > 3*f)
                return false;
            else return true;
        } else if(f == 0 && t > 0) {
            if(t >= sum())
                return true;
            else return false;
        }else{
            if(2*f+t >= sum())
                return true;
            else return false;
        }
    }
}

int main() {
//    freopen("in.txt", "r", stdin);
    while(scanf("%d%d", &n, &k) == 2) {
        for(int i = 0; i < k; i++)
            scanf("%d", &a[i]);
        sort(a, a+k, cmp);
        puts(Ju() ? "Yes" : "No");
    }
    return 0;
}

#include<iostream>
using namespace std;
int arr[1000000];
int main(){
int n, k;
cin>>n>>k;
for(int i=0; i<k; i++)
    cin>>arr[i];
int twos=2*n, fours=n, ones=0;
for(int i=0; i<k; i++){
    while(arr[i]>=4){
        if(fours>0)
            fours--;
        else
            twos-=2;
        arr[i]-=4;
    }
}
for(int i=0; i<k; i++){
    if(arr[i]==3){
        if(fours>0)
            fours--;
        else
            twos-=2;
    }
    if(arr[i]==2){
        if(twos>0)
            twos--;
        else{
            fours--;
            ones++;
        }
    }
    if(arr[i]==1){
        if(ones>0)
            ones--;
        else if(twos>0)
            twos--;
        else if(fours>0){
            fours--;
            twos++;
        }
        else{
            cout<<"NO";
            return 0;
        }
    }
}
if(twos<0 || fours<0){
    cout<<"NO";
    return 0;
}
cout<<"YES";
return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n,k;
	cin >> n >> k;
	ll a[k+5]={0};
	ll has[10]={0};
	ll t = 0;
	for(int i=0;i<k;i++){
		cin >> a[i];
		t += a[i]/4;
		a[i] %= 4;
		has[a[i]]++;
	}
	int rem4 = 0;
	int rem2 = 2*n;
	if(t<=n){
		rem4 = n-t;
	}
	else {
		rem2 -= 2*(t-n);
	}
	has[2] += has[3];
	has[1] += has[3];
	if(rem4>0){
		has[2] -= rem4;
		has[1] -= rem4;
		rem4 = 0;
	}
	//cout << has[2] << " " << rem2 << " " << rem4 << "\n";
	if(has[1]>0)rem2 -= has[1];
	if(has[2]>0)rem2 -= has[2];
	if(rem2>=0&&rem4>=0){
		cout << "YES\n";
	}
	else cout << "NO\n";
	//cout << has[2] << " " << rem2 << " " << rem4 << "\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define int long long
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif

	int n, k;
	cin >> n >> k;
	int four = n;
	int two = 2 * n;
	debug(four, two);
	bool ok = true;
	vector<int> a(k);
	for(int i = 0; i < k; ++ i)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end(), greater<int>());
	int need1 = 0, need2 = 0, need4 = 0;
	for(int i = 0; i < k; ++ i)
	{
		need4 += a[i] / 4;
		int lft = a[i] % 4;
		if(lft == 0)
			continue;
		if(lft == 1)
			++ need1;
		if(lft == 2)
			++ need2;
		if(lft == 3)
			++ need2, ++ need1;
	}
	debug(need1, need2, need4);
	int one = 0;
	if(four >= need4)
	{
		four -= need4;
		need4 = 0;
	}
	else
	{
		need4 -= four;
		four = 0;
		need2 += 2 * need4;
		need4 = 0;
	}
	if(two >= need2)
	{
		two -= need2;
		need2 = 0;
	}
	else
	{
		need2 -= two;
		two = 0;
		if(four >= need2)
		{
			four -= need2;
			one += need2;
			need2 = 0;
		}
		// else
		// {
			// ok = false;
		// }
	}
	debug("before", one);
	one += two + 2 * four;
	debug("after", one);
	need1 += need2;
	need2 = 0;
	if(one >= need1)
	{
		one -= need1;
		need1 = 0;
	}
	else
	{
		need1 -= one;
		one = 0;
	}
	debug(need1, need2, need4);
	if(need1 + need2 + need4 == 0)
		cout << "YES\n";
	else
		cout << "NO\n";

	// cout << (ok ? "YES\n" : "NO\n");

	return 0;
}

#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k;
	std::cin >> n >> k;
	int ans = 0;
	int got = 0;
	int one = 0;
	while(k--) {
		int x;
		std::cin >> x;
		if(x % 2 != 0) {
			x--;
			one++;
		}
		got += x / 4;
		if(x % 4 == 2) {
			ans++;
		}
	}
	//std::cout << got << ' ' << ans << '\n';
	int use = std::min(n, one / 2);
	one -= use * 2;
	int lul = use;
	use = std::min(n - use, got);
	got -= use;
	ans += 2 * got;
	got = 0;
	//std::cout << got << ' ' << ans << '\n';
	int wtf = n - use - lul;
	use = wtf;
	use = std::min(use, one);
	one -= use;
	one = 0;
	ans += one;
	use = wtf;
	use = std::min(use, ans);
	ans -= use;
	//std::cout << got << ' ' << ans << '\n';
	use = std::min(ans, 2 * n);
	ans -= use;
	//std::cout << got << ' ' << ans << '\n';
	if(ans + got != 0) {
		std::cout << "NO\n";
	} else {
		std::cout << "YES\n";
	}
}

#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
#include<stack>
#include<deque>
#include<algorithm>
#include<cmath>
#include<cmath>
#include<map>
using namespace std;
long long i,j,k,l,m,n,x,y,sum = 0,r,num = 0,two=0,four=0,er,si;
long long a[10005];
int main()
{
    scanf("%lld%lld",&m,&n);
    er = 2*m;
    si = m;
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
        if(a[i]==2)
            two += 1;
        if(a[i]==4)
            four +=1;
        if(a[i]==6)
        {
            four+=1;
            two+=1;
        }
        if(a[i]==8)
            four+=2;
    }
    r = m*8;
    if(sum+n-1<=r)
        printf("YES\n");
    else
    {
        si = si-four;
        if(si<0)
            er+=si;

        if(er<0)
            two+=er;
        else
        {
            er = er - two;
            if(er<0)
                two+=er;
        }
        if(sum+n-1-two-four<=r)
            printf("YES\n");
        else
            printf("NO\n");
    }
}

#include <cstdio>
using namespace std;
typedef long long ll;
int main(){
    ll K,N;
    ll res2=0,res4=0,res1=0;
    scanf("%lld%lld",&K,&N);
    while(N--){
        ll x;
        scanf("%lld",&x);
        if(x%2==1)res1++,x--;
        res4+=x/4;
        res2+=(x%4)/2;
    }
    ll cnt2=2*K,cnt1=0;
    if(res4>K){
        res2+=(res4-K)*2;
    }
    else{
        cnt2+=(K-res4);
        cnt1+=(K-res4);
    }
    if(cnt2>=res2&&(cnt1+cnt2)>=(res1+res2))printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include <iostream>
#include <queue>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;

	priority_queue<int> pq;
	for (int i = 0; i < k; i++) {
		int v;
		cin >> v;
		pq.push(v);
	}
	int r = 0;
	int c = 0;
	while (!pq.empty()) {
		int v = pq.top();
		pq.pop();
		c += 2;
		if (c >= 8) {
			c = 0;
			r++;
			if (r >= n) {
				break;
			}
		}
		v -= min(2, v);
		if (v > 0) {
			pq.push(v);
		}
	}
	if (pq.empty()) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

#include <iostream>
#define _USE_MATH_DEFINES
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <stack>
#include <map>
#include <ctime>
#include <bitset>
#include <fstream>
#include<stdlib.h>
using namespace std;

vector<vector<int> >g;
vector<int>num(100001,0);
vector<bool>used;
int cnt=0;
void dfs(int v,int len=0)
{
    used[v]=true;
    bool flag=true;
    for(int i=0;i<g[v].size();++i)
    {
        if(!used[g[v][i]]) flag=false,dfs(g[v][i],len+1);
    }
    if(flag) num[len]++,cnt++;
}

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>mas(k);
    for(int i=0;i<k;++i) cin>>mas[i];
    int four=n,dua=2*n;
    int i=0;
    int uno=0;
    while(four&&(i!=k))
    {
        int x=mas[i]/4;
        //cout<<four<<' '<<x;
        if(x<=four) four-=x,mas[i]%=4,++i;
        else mas[i]-=four*4,four=0;
    }
    i=0;

    if(four) uno+=2*four;
    while(dua&&(i!=k))
    {

        int x=mas[i]/2;
       //cout<<i<<' '<<dua<<' '<<x<<'\n';
        if(x<=dua) dua-=x,mas[i]%=2,++i;
        else
        {
            if(four) four--,mas[i]-=2,++i,--uno;
            else mas[i]-=dua*2,dua=0;
        }
    }
    //cout<<mas[0]<<mas[1];
    //cout<<dua;

    if(dua) uno+=dua;
    if(four) uno+=2*four;
    i=0;

    while(uno&&(i!=k))
    {
        //cout<<uno<<' '<<mas[i];
        if(mas[i]<=uno) uno-=mas[i],mas[i]=0,++i;
        else uno=0;
    }
    for(int i=0;i<k;++i)
    {
        if(mas[i])
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cctype>
#include <cstdlib>
using namespace std;

const int maxk = 100 + 5;

int n , k;
int a[maxk];

int main()
{
	cin >> n >> k;
	int s4 = n , s2 = 2 * n , s3 = 0 , s1 = 0 ,x1 = 0;
	for (int i = 1; i <= k; i++)
	{
		int x;
		cin >> x;
		if (x >= 4)
		{
			if (s4)
			{
				int t = min(s4 , x / 4);
				s4 -= t , x -= 4 * t;
			}
			if (s2 / 2)
			{
				int t = min(s2 / 2 , x / 4);
				s2 -= 2 * t , x -= 4 * t;
			}
		}
		if (x == 3)
		{
			if (s3)
				s3-- , x -= 3;
			else if (s4)
				s4-- , x -= 3;
			else if (s2 / 2)
				s2 -= 2 , x -= 3;
		}
		if (x == 2)
		{
			if (s2)
				s2-- , x -= 2;
			else if (s3)
				s3-- , x -= 2;
			else if (s4)
				s4-- , s1++ , x -= 2;
		}
		if (x == 1)
		{
			if (s1)
				s1-- , x--;
			else if (s2)
				s2-- , x--;
			else if (s3)
				s3-- , s1++ , x--;
			else if (s4)
				s4-- , s2++ , x--;
		}
		if (x)
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

#include <bits/stdc++.h>
#include <iostream>

#define MAX 200010
#define LIM 2000000010
using namespace std;

/*bool mycomp(pair<pair<int,int>,long int> x, pair<pair<int,int>,long int> y){

    return  x.first.first < y.first.first;

}

struct Cmp
{
    bool operator ()(const pair<pair<int,int>, long int> &a, const pair<pair<int,int>, long int> &b)
    {
        return a.first.second < b.first.second;
    }
};*/

int main(){

    int n, k;
    cin >> n >> k;
    int c2 = n*2;
    int c4 = n;
    int c1 = 0;
    vector<int> A(k);
    for(int i=0;i<k;i++){
        cin >> A[i];
    }
    //cout << "0" << endl;
    for(int i=0;i<k;i++){
        while(A[i] >= 3 && c4 > 0){
            if(A[i] >= 4){
                A[i]-=4;
                c4--;
            }else if(A[i] == 3){
                A[i]-=3;
                c4--;
            }
        }
        if(c4==0){
            break;
        }
    }
    //cout << "1" << endl;
    for(int i=0;i<k;i++){
        while(A[i] >= 2 && c2 > 0){
            if(A[i] >= 2){
                A[i]-=2;
                c2--;
            }
        }
        if(c2==0){
            break;
        }
    }
    //cout << "2" << endl;
    for(int i=0;i<k;i++){
        if(A[i] == 2 && c4 > 0){
            A[i]-=2;
            c4--;
            c1++;
        }
    }
    //cout << "3" << endl;
    for(int i=0;i<k;i++){
        if(A[i] == 1 && c4 > 0){
            A[i]-=1;
            c4--;
            c2++;
        }
    }
    for(int i=0;i<k;i++){
        while(A[i] >= 1 && c2 > 0){
            A[i] -= 1;
            c2--;
        }
        if(c2==0){
            break;
        }
    }
    //cout << "4" << endl;
    for(int i=0;i<k;i++){
        if(A[i] >= 1 && c1 > 0){
            A[i] -= 1;
            c1--;
        }
        if(c1==0){
            break;
        }

    }
    //cout << "5" << endl;
    for(int i=0;i<k;i++){
        if(A[i]!=0){
            //cout << A[i] << " " << i << endl;
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

#include <bits/stdc++.h>
#define ll   long long
#define ld long double
#define endl '\n'
using namespace std;
ll n;
ll k;
vector<ll> g[100005];
ll color[100005];
ld num[100005];
ll col = 0;
void dfs(ll v,ll p) {
    color[v]=col;
    num[col]++;
    for(ll i =0;i<g[v].size();i++) {
        if(g[v][i]!=p && color[g[v][i]]==0) dfs(g[v][i],v);
    }
}
ll pw(ll a,ll b) {
    ll s =1;
    for(ll i =1;i<=b;i++) {
        s=(s*a)%1000000007;
    }
    return s;
}
int main()
{
 // freopen("input.txt","r",stdin);
//   freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    ll a[1005]={0};
    ll c4 = n;
    ll c2 =2*n;
    ll k1 =0;
    ll k2 =0;
    ll k3 =0;
    for(ll i =1;i<=k;i++) {
        cin>>a[i];
    }
    sort(a+1,a+1+k);
    for(ll i=k;i>=1;i--) {
        ll p = a[i];
        ll d = min(p/4,c4);
        c4-=d;
        p-=d*4;
        if(p==3 && c4>0) {p=0; c4--;}
        ll d2 = min(p/2,c2);
        c2-=d2;
        p-=d2*2;
        if(p%2==1 && c2>0) {c2--; p=0;}
        if(p==1) k1++;
        if(p==2) k2++;
        if(p==3) k3++;
        if(p>=4) {cout<<"NO"; return 0;}
    }
    c4-=k3;
    while(k2>=k1 && k2>0){
        k2--;
        k1+=2;
    }
    c4-=k2;
    k1-=k2;
    if(k1>0) {
    c4-=(k1/2);
    c4-=k1%2;
    }
    if(c4<0) cout<<"NO"; else
    cout<<"YES";
}

#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> PII;
typedef pair<int, PII> PLL;
const int INF = 0x3f3f3f3f;
const int MAX_N = 1e5 + 10;
const LL mod = 1e9 + 7;
const double PI=acos(-1);
int cnt[5];
int main()
{
    int n, k, x;
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= k; ++i){
        scanf("%d", &x);
        cnt[4] += x / 4;
        cnt[x % 4]++;
    }
    int m = cnt[4] + cnt[3] + min(cnt[2] , cnt[1]);
    if(m <= n){
        if(cnt[2] >= cnt[1]){
            if(cnt[2] - cnt[1] <= n * 2 + (n - m) * 3 / 2)    puts("YES");
            else    puts("NO");
        }
        else{
            if(cnt[1] - cnt[2] <= n * 2 + (n - m) * 2)    puts("YES");
            else    puts("NO");
        }
    }
    else{
        m -= n;
        if(m + max(cnt[2] , cnt[1]) - min(cnt[1], cnt[2]) <= n * 2)    puts("YES");
        else    puts("NO");
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int n,k,a[10005];
int n_2,n_4;

int main()
{
	scanf("%d%d",&n,&k);
	n_4=n;n_2=n*2;
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&a[i]);
		if(n_4*4>=a[i]) {n_4-=a[i]/4;a[i]%=4;}
		else if(n_4>0) {a[i]-=n_4*4;n_4=0;}
	}
	if(n_4>0)
	{
		for(int i=1;i<=k;i++)
			if(a[i]==3&&n_4>0) {a[i]=0;n_4--;}
		if(n_4>0)
		{
			int sum_1=0,sum_2=0;
			for(int i=1;i<=k;i++)
				if(a[i]==1) sum_1++;
				else if(a[i]==2) sum_2++;
			if(n_4<sum_1&&n_4<sum_2)
			{
				sum_1-=n_4;sum_2-=n_4;
				if(n_2<sum_1+sum_2) printf("NO");
				else printf("YES");
			}
			else if(n_4>sum_1&&n_4>sum_2) printf("YES");
			else
			{
				n_4-=min(sum_1,sum_2);
				if(sum_2>=sum_1)
				{
					int last=sum_2-sum_1;
					if(n_4+n_2<last) printf("NO");
					else printf("YES");
				}
				else
				{
					int last=sum_1-sum_2;
					if(n_4*2+n_2<last) printf("NO");
					else printf("YES");
				}
			}
		}
		else
		{
			for(int i=1;i<=k;i++)
			{
				if(a[i]%2==1) n_2-=(a[i]+1)/2;
				else n_2-=a[i]/2;
			}
			if(n_2<0) printf("NO");
			else printf("YES");
		}
	}
	else
	{
		for(int i=1;i<=k;i++)
		{
			if(a[i]%2==1) n_2-=(a[i]+1)/2;
			else n_2-=a[i]/2;
		}
		if(n_2<0) printf("NO");
		else printf("YES");
	}
	return 0;
}

#include <iostream>
#include <set>
#include <algorithm>

using namespace std;
int a[102], inp[102];

set<int> odd;

int main()
{
    int n, k;
    int cnt=1, m=0;
    int i;

    cin >> n >> k;
    for(i=1;i<=k;i++)
        cin >> inp[i];
    sort(inp+1, inp+k+1);
    for(i=1;i<=k;i++)
        a[i]=inp[k-i+1];
    for(i=1;i<=k;i++)
        if(a[i]%2)
            odd.insert(i);

    for(i=1;i<=k;i++){
        while(a[i]>=4){
            if(cnt>n)
                break;
            a[i]-=4, cnt++;
        }
        if(cnt>n)
            break;
        if(odd.find(i)!=odd.end())
            odd.erase(i);
        if(a[i]==3)
            a[i]=0, cnt++;
        if(a[i]==2){
            if(m<=2*n){
                a[i]=0, m++;
                continue;
            }
            if(!odd.empty())
                a[*odd.begin()]--, odd.erase(odd.begin());
            else{
                a[k]--;
                if(a[k])
                    odd.insert(k);
                else
                    k--;
            }
            a[i]=0, cnt++;
        }
        if(a[i]==1)
            a[i]=0, a[i+1]-=2, cnt++;
    }
    cnt=m;
    for(i=1;i<=k;i++){
        while(a[i]>=1){
            a[i]-=2, cnt++;
        }
    }

    if(cnt>2*n){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second

#define ler freopen("inspection.in","r",stdin);freopen("inspection.out","w",stdout)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define debug cout<<"ACM ICPC\n"

#define pdd pair<ld,ld>
#define ll long long
#define ld long double
#define vi vector<int>
#define pii pair<int,int>

#define MAXN 1000006
#define LOG 21
#define EPS 1e-8
#define INF 1e12L

int n, k, v[10004], um, dois, a, b;
multiset <int> q;

int main(){
	cin >> n >> k;

	a= 2*n;
	b= n;

	bool ans=true;

	rep(i,0,k){
		cin >> v[i];
	}
	sort(v,v+k);

	rep(i,0,k){
		int aux= min(a, v[i]/2);
		a-= aux;
		v[i]-= aux*2;

		if(v[i]>=3){
			aux= min(b, v[i]/4);
			b-= aux;
			v[i]-= aux*4;
			if(v[i]==3){
				v[i]=0;
				b--;
			}
			if(b<0) ans=false;
		}

		if(v[i]==2){
			dois++;
		}
		else if(v[i]==1)
			um++;
	}

	int aux= min(dois, a);
	dois-= aux;
	a-= aux;

	if(dois>0){
		if(dois > b) ans=false;
		else{
			a+= dois;
			b-= dois;
			dois= 0;
		}
	}

	if(um > 3*b + a)
		ans=false;

	if(ans) cout << "YES\n";
	else cout << "NO\n";
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

/***********
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}.

Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.

Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.

Input
The first line contains two integers n and k (1 ≤ n ≤ 10000, 1 ≤ k ≤ 100) — the number of rows and the number of groups of soldiers, respectively.

The second line contains k integers a1, a2, a3, ..., ak (1 ≤ ai ≤ 10000), where ai denotes the number of soldiers in the i-th group.

It is guaranteed that a1 + a2 + ... + ak ≤ 8·n.

Output
If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes).

You can choose the case (lower or upper) for each letter arbitrary.

***********/

void remain(int& rest, int& seats, int k)
{
	while (rest >= k && seats > 0)
	{
		rest -= k;
		seats--;
	}
}

void remainB(int& rest, int& seats, vector<int>& v)
{
	if (seats > 0)
	{
		auto iter = v.begin();
		while (rest > 0 && iter != v.end())
		{
			if (*iter == 4 && rest > 1)
			{
				rest -= 2;
				*iter -= 2;
				++iter;
			}
			else if (*iter == 4 && rest < 2)
			{
				rest -= 1;
				*iter -= 1;
				++iter;
			}
			else if (*iter == 3 && rest > 1)
			{
				rest -= 2;
				*iter = 0;
				--seats;
				++iter;
			}
			else if (*iter == 3 && rest < 2)
			{
				rest -= 1;
				*iter = 0;
				--seats;
				++iter;
			}
			else if (*iter == 2)
			{
				rest -= 1;
				*iter = 0;
				--seats;
				++iter;
			}
			else
			{
				*iter = 0;
				--seats;
				++iter;
			}
		}
	}
}

int main()
{
	int rows, groups;
	cin >> rows >> groups;
	int A(rows);
	int B(rows);
	int C(rows);

	int people;
	vector<int> each_groups;
	each_groups.reserve(groups);
	for (int i(0); i < groups; ++i)
	{
		cin >> people;
		each_groups.push_back(people);
	}

	sort(each_groups.begin(), each_groups.end());
	bool YN = 1;
	for (auto iter = each_groups.begin(); iter != each_groups.end(); ++iter)
	{
		remain(*iter, B, 4);
		remain(*iter, B, 3);
		remain(*iter, A, 2);
		remain(*iter, C, 2);
		remain(*iter, A, 1);
		remain(*iter, C, 1);

		vector<int> v(B, 4);
		remainB(*iter, B, v);

		//cout << "(" << *iter << ", " << A << ", " << B << ", " << C << ")" << endl;
		if (*iter > 0)
		{
			YN = 0;
			cout << "NO" << endl;
			break;
		}
	}
	if (YN == 1)
	{
		cout << "YES" << endl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

int main() {
	cin.sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	vi nums(k);
	rep(i,0,k) cin >> nums[i];
	sort(nums.rbegin(), nums.rend());
	rep(i,0,n) {
		int at = 0;
		int left = 8;
		rep(a,0,k) {
			int minus = min(nums[a],4);
			minus = min(minus,left);
			left -= minus;
			nums[a] -= minus;
		}
		sort(nums.rbegin(), nums.rend());
	}

	bool ok = true;
	rep(i,0,k) if(nums[i] != 0) ok = false;
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

#include <iostream>
#include <algorithm>
#define MAXN 100

using namespace std;

int N, K, groups[MAXN + 2];

bool desc(int i, int j) {
	return i > j;
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < K; i++)
		cin >> groups[i];

	sort(groups, groups + K, desc);

	int right_remaining = 4 * N;
	int left_remaining = 4 * N;
	for (int i = 0; i < K; i++) {
		if (right_remaining >= left_remaining) {
			right_remaining -= groups[i];
		}
		else {
			left_remaining -= groups[i];
		}
	}

	if (right_remaining >= 0 && left_remaining >= 0)
		cout << "YES" << endl;
	else {
		cout << "NO" << endl;
	}
	return 0;
}

#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#define N 100005
using namespace std;
int n,k,x,px=0,py=0,pz=0,a,b;
int read(){
    int ans=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();}
    return ans*f;
}
int main(){
	std::ios::sync_with_stdio(false);
	n=read();k=read();
	for (int i=0;i<k;i++){
		x=read();
		a=x%4;x/=4;px+=x;
		b=a%2;a/=2;py+=a;
		pz+=b;
	}
	if (px>=n){
		px-=n;py+=px*2;py+=pz;
		if (py>2*n) {cout<<"NO";return 0;}
	}else{
		if (py>2*n){
			py-=2*n;
			px+=max(py,pz);
			if (px>n) {cout<<"NO";return 0;}
		}else if ((2*n-py+n-px)<pz) {cout<<"NO";return 0;}
	}
	cout<<"YES";
	return 0;
}

#include <iostream>
#include <queue>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;

	priority_queue<int> pq;
	for (int i = 0; i < k; i++) {
		int v;
		cin >> v;
		pq.push(v);
	}
	int r = 0;
	while (r < n && !pq.empty()) {
		int v = pq.top();
		pq.pop();
		v -= min(2, v);
		if (v > 0) {
			pq.push(v);
		}
		if (pq.empty()) {
			break;
		}
		v = pq.top();
		pq.pop();
		v -= min(2, v);
		if (v > 0) {
			pq.push(v);
		}
		if (pq.empty()) {
			break;
		}
		v = pq.top();
		pq.pop();
		if (v >= 3) {
			v -= min(4, v);
			if (v) {
				pq.push(v);
			}
		} else if (v == 2) {
			if (!pq.empty() && pq.top() < 2) {
				pq.pop();
			}
		} else if (!pq.empty()) {
			pq.pop();
		}
		if (!pq.empty()) {
			r++;
		}
	}
	if (pq.empty()) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

              #include <bits/stdc++.h>
              using namespace std;
              #define int long long int
              #define ff first
              #define ss second
              #define ll  int
              vector<int >v;
              int32_t main() {

              ios_base::sync_with_stdio(false);
              cin.tie(NULL);

                int t=1;

                //cin >> t;
                while(t--)
                {
                   int n,k;
                   cin >> k >> n;

                   int a[n]  , p=k , q = 2*k;
                   for(int i=0; i<n; i++)
                   cin >> a[i];

                   for(int i=0; i<n; i++)
                   {
                   	int x= a[i]/4;
                   	if(p>x)
                   	{
                   		p-=x;
                   	}
                   	else
                   	{   x-=p;
                   		p=0;
                   		x = 2*x+ ((a[i]%4)/2)+ ((a[i]%4)%2);
                   		if(q>x)
                   		{
                   			q-=x;
                   		}
                   		else
                   		{
                   			cout << "NO\n";
                   			return 0;
                   		}
                   	}

                   }

                   cout <<"YES\n";
                }

                                            return 0;
                }

#include<iostream>
#include<algorithm>
using namespace std;
int n, k, num[5],sum=0;
int a[105];
int main()
{
	cin >> n >> k;
	num[1] = num[2]=num[4]=n;
	int i;
	for (i = 1; i <= k; i++)
	{
		cin >> a[i];
		if (a[i] >= 4)
		{
			num[4] -= a[i] / 4;
			if (a[i] % 4 == 3)
			{
				num[2]--;
				num[3]--;
			}
			else if(a[i]%4!=0)
				num[a[i] % 4]--;
		}
		else if (a[i] == 3)
		{
			num[1]--;
			num[2]--;
		}
		else num[a[i]]--;
		if (!num[1] && !num[2] && !num[4])
			break;
	}
	if (i>k)
		cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int seat[10001][9]={0},k=1,j=1;
int Greater_3(vector<int>group[],int row)
{
    int Size=group[4].size();
    for(int i=0;i<Size;i++)
    {
        for(int grp_size=group[4][i];grp_size>3;)
        {
            if(j<=row)
            {
                seat[j][3]=1;
                seat[j][4]=1;
                seat[j][5]=1;
                seat[j][6]=1;
                grp_size-=4;
                j++;
            }
            else if(k<=row)
            {
                seat[k][1]=1;
                seat[k][2]=1;
                seat[k][7]=1;
                seat[k][8]=1;
                grp_size-=4;
                k++;
            }
            else
                return 0;
            if(grp_size<4)
            {
                group[grp_size].push_back(grp_size);
                break;
            }
        }
    }
    return 1;
}
int Equal_3(vector<int>group[],int row)
{
    int Size=group[3].size();
    for(int i=0;i<Size;i++)
    {
        if(j<=row)
        {
            seat[j][3]=1;
            seat[j][4]=1;
            seat[j][5]=1;
            seat[j][6]=1;
            j++;
        }
        else if(k<=row)
        {
            seat[k][1]=1;
            seat[k][2]=1;
            seat[k][7]=1;
            seat[k][8]=1;
            k++;
        }
        else
            return 0;
    }
    return 1;
}
void Equal_2(vector<int>group[],int row)
{
    int p=j;
    int Size=group[2].size();
    for(int i=0;i<Size;i++)
    {
        if(p<=row)
        {
            seat[p][3]=1;
            seat[p][4]=1;
            seat[p][5]=1;
            p++;
        }
        else if(k<=row)
        {
            if(!seat[k][1])
            {
                seat[k][1]=1;
                seat[k][2]=1;
            }
            else
            {
                seat[k][7]=1;
                seat[k][8]=1;
                k++;
            }
        }
        else
        {
            group[1].push_back(1);
            group[1].push_back(1);
        }
    }
}
int Equal_1(vector<int>group[],int row)
{
    int Size=group[1].size();
    for(int i=0;i<Size;i++)
    {
        if(j<=row)
        {
            if(!seat[j][3])
            {
                seat[j][3]=1;
                seat[j][4]=1;
            }
            else
            {
                seat[j][5]=1;
                seat[j][6]=1;
                j++;
            }
        }
        if(k<=row)
        {
            if(!seat[k][1])
            {
                seat[k][1]=1;
                seat[k][2]=1;
            }
            else
            {
                seat[k][7]=1;
                seat[k][8]=1;
                k++;
            }
        }
        else
            return 0;
    }
    return 1;
}
int main()
{
    int n,k,grp_mem;
    scanf("%d%d",&n,&k);
    vector<int>group[5];
    while(k--)
    {
        scanf("%d",&grp_mem);
        if(grp_mem>3)
        {
            group[4].push_back(grp_mem);
        }
        else
        {
            group[grp_mem].push_back(grp_mem);
        }
    }
    if(!Greater_3(group,n))
    {
        printf("NO");
        return 0;
    }
    if(!Equal_3(group,n))
    {
        printf("NO");
        return 0;
    }
    Equal_2(group,n);
    if(!Equal_1(group,n))
    {
        printf("NO");
        return 0;
    }
    printf("YES");
    return 0;
}

#include<bits/stdc++.h>

#define f(i,a,n) for(int i=a;i<n;i++)
#define S second
#define F first
#define Sc(n) scanf("%lld",&n)
#define scc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sp(a) scanf("%lld %lld",&a.first,&a.second)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define sc(n) scanf("%d",&n)
#define It iterator
#define SET(a,b) memset(a,b,sizeof(a))
#define DRT()  int t; cin>>t; while(t--)

// inbuilt functions
// __gcd,  __builtin_ffs,     (returns least significant 1-bit, __builtin_ffsll(1)=1)
// __builtin_clz,             (returns number of leading zeroes in
// __builtin_popcount,

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> vi;
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define trv(s,it) for(auto it:s)

int main()
{
	int n,k;
	LL sum=0;
	cin>>n>>k;
	LL y=0,temp=0;
	f(i,0,k)
	{
		int a;
		cin>>a;
		if(a%2==1)
			temp++;
		y+=(a/2);
	}
	if(y+temp<=4*n)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <iterator>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define ld long double
#define ll long long

#define cont continue
#define re return

#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000

#define MINLL -9000000000000000000LL
#define MININT -2000000000

#define P acos(-1.)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

int a[181], n, i, j, k, sum, kol1, kol2, kol3;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;

    for (i = 1; i <= k; i++) cin >> a[i];

    kol1 = n * 2;

    kol2 = n;

    for (i = 1; i <= n; i++)
        for (j = 1; j <= k; j++)
            if (a[j] - 4 >= 0) {
                kol2--;

                a[j] -= 4;

                break;
            }

    if (kol2 == 0) {
        for (i = 1; i <= k; i++) sum += (a[i] + 1) / 2;

        if (sum <= kol1)
        cout << "YES";
        else cout << "NO";

        cout << endl;

        re 0;
    }

    for (i = 1; i <= k; i++)
        if (a[i] == 3) {
            if (kol2 - 1 >= 0)
            kol2--;
            else if (kol1 - 2 >= 0)
            kol1 -= 2;
            else {
                cout << "NO" << endl;

                re 0;
            }
        }

    for (i = 1; i <= k; i++)
        if (a[i] == 1) {
            kol3++;

            if (kol3 <= kol2)
            cont;

            if (kol1 - (kol3 - kol2))
            kol1--;
            else {
                cout << "NO" << endl;

                re 0;
            }
        }

    kol3 = 0;

    for (i = 1; i <= k; i++)
        if (a[i] == 2) kol3++;

    if (kol1 + kol2 >= kol3)
    cout << "YES";
    else cout << "NO";

    cout << endl;

    re 0;
}

#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

#define inf 100000000000000LL
#define md 1000000007

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}
template <typename T>inline T ModInv (T b,T m)
{
    return BMOD(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
/////////////

int n,k;
int arr[111];

int main()
{
    S2(n,k);
    int r=0,c=1;
    int mp[9];

    for(int i=1;i<=8;i++)mp[i]=0;

    for(int i=1;i<=k;i++)
    {
        S(arr[i]);

        int dv=arr[i]/8;

        r+=dv;

        int baki=arr[i]%8;

        mp[baki]++;
    }
    cerr<<r<<" "<<n<<" "<<(n-r)<<endl;

    for(int i=1;i<8;i++)cerr<<mp[i]<<" ";
//    NL;
    cerr<<"\n";
    int mn;
    c=0;
    int noshto=0;
    noshto+=mp[7];
    mp[7]=0;
    if(mp[6])
    {
        mn=min(mp[2],mp[6]);
        mp[6]-=mn;
        mp[2]-=mn;
        noshto+=mn;

        mn=min(mp[1],mp[6]);

        mp[1]-=mn;
        mp[6]-=mn;
        noshto+=(mn);

        noshto+=(mp[6]);
        c+=mp[6];
        mp[6]=0;
        cerr<<c<<" "<<noshto<<endl;
    }
    if(mp[5])
    {

        mn=min(mp[5],mp[2]);
        mp[2]-=mn;
        mp[5]-=mn;
        noshto+=mn;

        mn=min(mp[5],mp[1]);
        mp[5]-=mn;
        mp[1]-=mn;
        noshto+=(mn);

        noshto+=(mp[5]);
        c+=mp[5];
        mp[5]=0;
        cerr<<c<<" "<<noshto<<endl;
    }
    if(mp[4])
    {
        noshto+=(mp[4]/2);
        mp[4]%=2;

        mn=min(mp[4],mp[2]/2);
        mp[4]-=mn;
        mp[2]-=(2*mn);
        noshto+=mn;

        mn=min(mp[4],mp[3]);
        mp[3]-=mn;
        mp[4]-=mn;
        noshto+=mn;

        mn=min(mp[4],min(mp[2],mp[1]));
        mp[4]-=mn;
        mp[2]-=mn;
        mp[1]-=mn;
        noshto+=(mn);

        mn=min(mp[4],mp[2]);

        mp[4]-=mn;
        mp[2]-=mn;
//        mp[1]-=mn;

        noshto+=(mn);

        noshto+=(mp[4]);
        c+=(2*mp[4]);
        mp[4]=0;
        cerr<<c<<" "<<noshto<<endl;
    }
    if(mp[3])
    {

            mp[1]+=(2*(mp[3]/3));
            noshto+=(mp[3]/3);
            mp[3]%=3;

            mn=min(c,mp[1]);
            c-=mn;
            mp[1]-=mn;

        mn=min(mp[3],mp[2]/2);
        mp[3]-=mn;
        mp[2]-=(2*mn);
        noshto+=(mn);

        mn=min(mp[3],min(mp[2],mp[1]));
        mp[3]-=mn;
        mp[2]-=mn;
        mp[1]-=mn;
        noshto+=(mn);

        mn=min(mp[3],mp[2]);
        mp[3]-=mn;
        mp[2]-=mn;
        c+=mn;
        noshto+=(mn);

        mn=min(mp[3],mp[1]/2);
        mp[3]-=mn;
        mp[1]-=(2*mn);
        noshto+=(mn);

        mn=min(mp[3],mp[1]);
        mp[3]-=mn;
        mp[1]-=mn;
        c+=mn;
        noshto+=(mn);
        noshto+=(mp[3]);
        cerr<<c<<" "<<noshto<<endl;
    }
    if(mp[2])
    {
        if(c)
        {
            mn=min(c,mp[2]);
            mp[2]-=mn;
            c-=mn;
        }

        mn=min(mp[1],mp[2]/3);
        mp[1]-=mn;
        mp[2]-=(3*mn);
        noshto+=mn;

        int pp=mp[2]/3;
        c+=pp;
        mp[2]-=pp*3;
        noshto+=(pp);

        mn=min(mp[1],mp[2]/2);
        c+=mn;
        mp[1]-=mn;
        mp[2]-=(2*mn);

        noshto+=(mn);

        pp=mp[2]/2;
        c+=(2*pp);
        mp[2]-=(2*pp);
        noshto+=(pp);

        mn=min(mp[2],mp[1]);
        c+=(2*mn);
        mp[2]-=mn;
        mp[1]-=mn;
        noshto+=(mn);

        noshto+=(mp[2]);
        c+=(3*mp[2]);
        mp[2]=0;
        cerr<<c<<" "<<noshto<<endl;

    }

    mn=min(c,mp[1]);
    mp[1]-=mn;
    c-=mn;

    noshto+=(mp[1]/4);
    mp[1]%=4;

    cerr<<c<<" "<<noshto<<" "<<mp[1]<<endl;

    noshto+=(mp[1]/3);
    mp[1]%=3;

    noshto+=mp[1]/2;
    mp[1]%=2;

    noshto+=mp[1];

    r+=noshto;
    cerr<<r<<endl;

    if(r<=n)printf("YES\n");
    else printf("NO\n");

    return 0;
}

// if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}.
/*
3403 59

1269 1612 453 795 1216 941 19 44 1796 324 2019 1397 651 382 841 2003 3013 638 1007 1001 351 95 394 149 125 13 116 183 20 78 208 19 152 10 151 177 16 23 17 22 8 1 3 2 6 1 5 3 13 1 8 4 3 4 4 4 2 2 3378

*/

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,ans,s,a[100010];
int main(){
	cin>>n>>k;
	for(int i=0;i<k;i++)
		cin>>a[i];
	ll db =n*2;
	ll qd=n;
	for(int i=0;i<k;i++){
		while(a[i]>=4 && qd){
			a[i]-=4;
			qd--;
		}
	}
	if(!qd){
		for(int i=0;i<k;i++){
			while(a[i]>0 && db){
				db--;
				a[i]-=2;
			}
		}
		if(a[k-1]<=0){
			cout<<"YES";
			return 0;
		}
		else{
			cout<<"NO";
			return 0;
		}
	}
	for(int i=0;i<k;i++){
		while(a[i]>=2 && db){
			a[i]-=2;
			db--;
		}
		if(!db){
			if(a[i]==3){
				qd--;
				a[i]=0;
			}
			if(!qd && a[i]){
//				cout<<qd<<db<<endl;
				cout<<"NO";
				return 0;
			}
		}
	}
	ll hai,mot;
	hai=0;
	mot=0;
	for(int i=0;i<k;i++){
		if(a[i]==2 && db){
			a[i]=0;
			db--;
		}
	}
	for(int i=0;i<k;i++){
		if(a[i]==2){
			hai++;
		}
		if(a[i]==1){
			mot++;
		}
	}
//	cout<<qd<<db<<mot<<hai<<endl;
	if( hai==0){
		if(mot<=db+ qd*2){
		cout<<"YES";
		return 0;

		}
	}
	cout<<hai<<" "<<db<<endl;
	if(hai!=0){
		if(hai<=db && mot<= qd*2 + db-hai){
			cout<<"YES";
			return 0;
		}
		if(hai>db){
			hai-=db;
			cout<<hai<<qd<<endl;
			if((hai+mot<=qd*2 && hai<=qd) || (hai-qd)<=qd ){
				cout<<"YES";
				return 0;
			}
		}
	}
	cout<<"NO";
//	`12345677890-=	qwertyuiop[?\ASDFGHJKL;'ZXCVBNM,./']
}

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int a[111];
	int need = 0;
	for (int i = 0; i < k; i++){
		scanf("%d", &a[i]);
		if (a[i] % 2 == 1)
			a[i]++;
		need += a[i];
	}
	if (need <= 8*n){
		cout << "YES" << endl;
	}
	else
		cout << "NO" << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <sstream>
#include <queue>
#include <iomanip>

using namespace std;

map<string, int> m;

int main()
{
	ios_base::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	int two, four;
	two = four = n * 4;
	int count1 = 0;
	int count2 = 0;
	bool nofour = false;

	for (int i = 0; i < k; ++i)
	{
		int v;
		cin >> v;
		int mod = v % 4;

		if (four < v - mod)
		{
			count2 += (v - mod - four) / 2;
			four = 0;
		}
		else
			four -= v - mod;

		if (mod == 3)
		{
			if (four == 0)
			{
				if (two == 0)
				{
					cout << "NO" << endl;
					return 0;
				}
				two -= 4;
				continue;
			}
			four -= 4;
			continue;
		}
		else if(mod == 1)
		{
			++count1;
		}
		else if (mod == 2)
		{
			++count2;
		}
	}

	while (four != 0 && count1 != 0 && count2 != 0)
	{
		--count1;
		--count2;
		four -= 4;
	}

	int total = two / 2 + four / 4;
	if (count1 + count2 <= total)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
const int   oo = 1e9 + 1;
const int  mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int n, k, a[maxn], flag2, flag4, i, flag1;
bool res = true;

void Init()
{
    cin >> n >> k;
    for (i = 1; i <= k; ++i)
    {
        cin >> a[i];
        while (a[i] > 0)
        {
            if (a[i] == 1 && flag1 > 0)
            {
                flag1--; a[i] = 0; break;
            }
            if (a[i] > 2)
            {
                if (flag4 < n) flag4++, a[i] -= 4;
                else if (flag2 < 2 * n) flag2++, a[i] -= 2;
            }
            else
            {
                if (flag2 < 2 * n) flag2++, a[i] -= 2;
                else if (flag4 < n)
                {
                    flag4++;
                    if (a[i] == 2) flag1++;
                    if (a[i] == 1) flag2--;
                    a[i] -= 4;
                }
            }
            if (flag2 == 2 * n && flag4 == n && flag1 > 0) flag1--, a[i]--;

            if (flag2 == 2 * n && flag4 == n && flag1 == 0 && a[i] > 0)
            {
                res = false; break;
            }
        }
        //cerr << flag2 << " " << flag4 << endl;
    }
    if (res) cout << "YES";
    else cout << "NO";
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("Div428B.inp", "r", stdin);
    //freopen(".out", "w", stdout);

	Init();
}
//Date 10 Month 7 Year 2017

#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k;
	std::cin >> n >> k;
	int ans = 0;
	int got = 0;
	int one = 0;
	while(k--) {
		int x;
		std::cin >> x;
		if(x % 2 != 0) {
			x--;
			one++;
		}
		got += x / 4;
		if(x % 4 == 2) {
			ans++;
		}
	}
	//std::cout << got << ' ' << ans << '\n';
	int use = std::min(n, got);
	got -= use;
	ans += 2 * got;
	got = 0;
	//std::cout << got << ' ' << ans << '\n';
	int wtf = n - use;
	use = wtf;
	use = std::min(use, one);
	one -= use;
	one = 0;
	ans += one;
	use = wtf;
	use = std::min(use, ans);
	ans -= use;
	//std::cout << got << ' ' << ans << '\n';
	use = std::min(ans, 2 * n);
	ans -= use;
	//std::cout << got << ' ' << ans << '\n';
	if(ans + got != 0) {
		std::cout << "NO\n";
	} else {
		std::cout << "YES\n";
	}
}

#include <bits/stdc++.h>

#define y1 theboatman
#define make_struct(args...) {args}

using namespace std;
typedef long long ll;

const long long INF = 1e18 + 10;
const int inf = 1e9 + 10;
const int N = 1e6 + 10;

struct osu {
    int left, mid, right;
};

int n, m;
vector <int> group;
vector <osu> row;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    cin >> n >> m;

    row.resize(n);
    for(int i = 0; i < n; i++) {
        row[i] = make_struct(0, 0, 0);
    }

    group.resize(m);
    for(int i = 0; i < m; i++) {
        cin >> group[i];
    }

    int now = 0;
    for(int i = 0; i < m; i++) {
        while(group[i] > 3 && now < m)  {
            row[now].mid = 1;
            group[i] -= 4;

            while(now < m && row[now].mid) {
                now++;
            }
        }
    }

    now = 0;
    for(int i = 0; i < m; i++) {
        while(group[i] > 1 && now < m) {
            if (row[now].left) {
                row[now].right = 1;
            }
            else {
                row[now].left = 1;
            }
            group[i] -= 2;

            while(now < m && row[now].left + row[now].right > 1) {
                now++;
            }
        }
    }

    now = 0;
    for(int i = 0; i < m; i++) {
        while(now < m && row[now].mid) {
                now++;
            }

        while(group[i] > 1 && now < m)  {
            row[now].mid = 2;
            group[i] -= 2;

            while(now < m && row[now].mid) {
                now++;
            }
        }
    }

    now = 0;
    for(int i = 0; i < m; i++) {
        while(now < m && row[now].left + row[now].right > 1) {
            now++;
        }

        while(group[i] && now < m) {
            if (row[now].left) {
                row[now].right = 1;
            }
            else {
                row[now].left = 1;
            }
            group[i]--;

            while(now < m && row[now].left + row[now].right > 1) {
                now++;
            }
        }
    }

    now = 0;
    for(int i = 0; i < m; i++) {
        while(now < m && row[now].mid != 2 && row[now].mid != 0) {
            now++;
        }

        while(group[i] && now < m) {
            if (!row[now].mid) {
                row[now].mid = 2;
            }
            else {
                row[now].mid = 1;
            }

            group[i]--;

            while(now < m && row[now].mid != 2 && row[now].mid != 0) {
                now++;
            }
        }
    }

    for(auto i : group) {
        if (i) {
            return cout << "no\n", 0;
        }
    }

    cout << "yes\n";
    return 0;
}
/*
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair

int n, k;
int a[100];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    for(int i = 0; i < k; i++) cin >> a[i];
    int cnt = 0;
    bool ok = false;
    for(int i = 0; i < k; i++){
        if((cnt + a[i] / 2 + 1) / 2 > n){
            int tmp = 2 * n - cnt;
            a[i] -= tmp * 2;
            cnt += tmp;
            ok = true;
            break;
        }
        cnt += a[i] / 2;
        a[i] %= 2;
    }
    if(ok){
        int left4 = n;
        for(int i = 0; i < k; i++){
            if(a[i] > 3){
                if(left4 - a[i] / 4 < 0){
                    a[i] -= left4 * 4;
                    left4 = 0;
                    break;
                }
                left4 -= a[i] / 4;
                a[i] %= 4;
            }
        }
        int left2 = left4, left1 = left4;
        for(int i = 0; i < k; i++){
            if(a[i] == 0) continue;
            int mn = min(left2, a[i] / 2);
            left2 -= mn;
            a[i] -= mn * 2;
            left1 -= a[i];
        }
        if(left2 >= 0 && left1 >= 0){
            cout << "YES" << endl;
        }
        else cout << "NO" << endl;
    }
    else{
        int sum = 0;
        for(int i = 0; i < k; i++){
            sum += a[i];
        }
        if(sum <= n * 4 - cnt){
            cout << "YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+1;
int a[101];
int main()
{
	int n,k,cnt=0;
	cin>>n>>k;
	for(int i=1;i<=k;++i)cin>>a[i];
	int cnt4=n,cnt2=2*n;
	for(int i=1;i<=k;++i)
	{
		int c=a[i]/8;
		cnt4-=c;cnt2-=c*2;
		a[i]=a[i]%8;
		if(!a[i])continue;
		if(a[i]>=1&&a[i]<=2)cnt2--;
		if(a[i]>=3&&a[i]<=4)cnt4--;
		if(a[i]>=5&&a[i]<=6)cnt2--,cnt4--;
		if(a[i]>=7&&a[i]<=8)cnt4--,cnt2-=2;
	}
	while(cnt4<0)cnt4++,cnt2-=2;
	while(cnt2<0)cnt2+=2,cnt4--;
	if(cnt2>=0&&cnt4>=0)cout<<"yes";
	else    cout<<"no";
}

#include <conio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    int n,k,free=0,foll=0,res=0,temple=0;
    cin>>n>>k;
    n=8*n;
    int x=n/2,y=n/2;
     int *arr=new int[k];
     int x1=0,x2=0,x3=0,x0=0;
    for(int i=0;i<k;i++)
    {
        arr[i]=0;
        cin>>arr[i];
        res=res+arr[i];
        if(arr[i]%4==2)
        {
            x2=x2+arr[i];
        }
        if(arr[i]%4==0)
        {
            x0=x0+arr[i];
        }
        if(arr[i]%4==1)
        {
            x1++;
        }
        if(arr[i]%4==3)
        {
            x3++;
        }
    }
    if(abs(y-x2)!=0)
    {
       if(abs(y-x2)%4!=0)
       {
          foll=foll+1;

       }
    }
    if(x3+x1>0)
    {
        foll=foll+x3+x1-1;
    }

    //sort(arr,arr+k,greater<int>());

if(res+foll<n)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}
//cout<<foll;
    //getch();
    return 0;

}
//

#include <bits/stdc++.h>
using namespace std;

int arr[8]={8,2,2,4,4,6,6,8};
int main(){
	int n,k;
	cin>>n>>k;
	int seat=n*8;
	for(int i=1;i<=k;i++){
		int grp;
		cin>>grp;
		if(seat<grp){
			cout<<"NO\n";
			return 0;
		}
		seat-=(grp/8)*8;
		grp=grp%8;
		seat-=arr[grp];
	}

	cout<<"YES\n";
	return 0;
}

/*
	Powered by Buggy plugin
*/

#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
const int MAX_N = 1e04+10;
int x[MAX_N];
priority_queue<int> Qj, Qo;
int main()
{
    int n,k;
    int mid = 0;
    int pan = 0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++){
        scanf("%d",&x[i]);
        if(x[i]%2==0)
            Qo.push(x[i]);
        else
            Qj.push(x[i]);
    }
    mid = n;
    pan = 2*n;
    int x;
    while(!Qj.empty()){
            if(mid<0&&pan<0)
            break;
        x = Qj.top();
        Qj.pop();
        if(x>=3){
            if(mid){
                mid--;
                x-=3;
            }
            else{
                x-=1;
                pan--;
            }
        }
        else{
            if(mid){
                x-=1;
                mid--;
                pan++;
            }
            else{
                x-=1;
                pan--;
            }
        }
        if(x>0)
            Qo.push(x);
    }
    int tot = 0;
    int half = 0;
    while(!Qo.empty())
    {
        x=Qo.top();
        if(mid<0&&pan<0)
            break;
        Qo.pop();
        if(mid)
        {
            if(x<4)
                half++;
            x-=4;
            mid--;
        }
        else{
            tot+=x;
            x=0;
        }
        if(x)
            Qo.push(x);
    }
    bool st = true;
    if(pan>=0&&tot>2*pan+half)
        st=false;
    if(mid>=0&&pan>=0&&st)
        printf("YES");
    else
        printf("NO");
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int Maxn=110;
int A[Maxn];
int main()
{
  int N,K; scanf("%d%d",&N,&K);
  for(int i=1;i<=K;i++) scanf("%d",&A[i]); int last=8*N; int last4=N,last2=2*N;
  for(int i=1;i<=K;i++)
  {
    int ned=min(A[i]/4,last4);
    last4-=ned; A[i]-=ned*4;
    if(last4==0) break;
  }
  for(int i=1;i<=K;i++)
  {
    int ned=min(A[i]/2,last2);
    last2-=ned; A[i]-=ned*2;
    if(last2==0) break;
  }
  int s1=0; int s2=0; int s3=0;
  for(int i=1;i<=K;i++)
  {
    if(A[i]>3){printf("NO\n"); return 0;}
    else if(A[i]==1) s1++;
    else if(A[i]==2) s2++;
    else if(A[i]==3) s3++;
  }
  while(last4)
  {
    if(!s1 && !s2 && !s3) break;

    if(s3>3)
    {
      int ned=min(last4/3,s3/4);
      s3-=ned*4; last4-=ned*3;
      continue;
    }

    if(s3)
    {
      int ned=min(last4,s3);
      s3-=ned; last4-=ned;
      continue;
    }

    if(s2>2)
    {
      int ned=min(last4/2,s2/3);
      last4-=ned*2; s2-=ned*3;
      continue;
    }

    if(s2 && s1>1)
    {
      int ned=min(last4/2,min(s1/2,s2));
      last4-=ned*2; s2-=ned; s1-=ned*2;
      continue;
    }

    if(s2 && s1)
    {
      int ned=min(last4,min(s1,s2));
      s1-=ned; s2-=ned; last4-=ned;
      continue;
    }

    if(s1>1)
    {
      int ned=min(last4,s1/2);
      s1-=2*ned; last4-=ned;
      continue;
    }

    if(s2)
    {
      int ned=min(last4,s2);
      s2-=ned; last4-=ned;
      continue;
    }

    if(s1)
    {
      int ned=min(last4,s1);
      s1-=ned; last4-=ned;
      continue;
    }
  }

  while(last2)
  {
    if(!s1 && !s2) break;
    if(s2)
    {
      int ned=min(last2,s2);
      s2-=ned; last2-=ned;
      continue;
    }

    if(s1)
    {
      int ned=min(last2,s1);
      s1-=ned; last2-=ned;
      continue;
    }
  }

  if(s1 || s2 || s3) printf("NO\n");
  else printf("YES\n");
  return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int a[110];
int b[10];
int main(){
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        int p=0;
        for(int i=0;i<k;i++){
            scanf("%d",&a[i]);
            n-=a[i]/8;
            a[i]=a[i]%8;
            b[2]+=a[i]/2;
            if(a[i]%2) b[1]++;
        }
        while(b[2]>2){
            if(b[1]==0) break;
            b[1]-=1;
            n--;
            b[2]-=3;
        }
        //printf("%d %d\n",b[2],b[1]);
        int sum=(b[2]+b[1])*2;
        if(sum>n*8) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
	int n,k,x;
	while(~scanf("%d %d",&n,&k)){
		int two = 0;
		int four = 0;
		double total = 0;
		for(int i = 0;i < k;i++){
			scanf("%d",&x);
			four += (x / 4);
			two += (ceil)((x - (x / 4) * 4) * 1.0 / 2);
			if((x - (x / 4) * 4) % 2 != 0){
				two++;
			}
		}
//		printf("%d %d\n",two,four);
		two = ceil(two * 1.0 / 2);
		int temp = two + four >> 1;
//		printf("%d\n",temp);
		if(temp <= n){
			puts("YES");
		}else{
			puts("NO");
		}
	}
}

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define r_all(v)  v.rbegin(),v.rend()
#define all(v)  v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define rep(n) for (int i = 0; i < n; ++i)
#define vs vector<string>
#define nrep(m)for(int j=0;j<m;j++)

// int gcd(int a,int b){
// 	if(b==0)return a;
// 	return gcd(b,a%b);
// }
// bool is_brime(int num ){
// 	if(num<2)return false;
// 	if(num==2)return true;
// 	if(!(num&1))return false;
// 	int i =3;
// 	for(;i*i<=num;i+=2){
// 		if(num%i==0)return false;
// 	}
// 	return true;
// }
void testCase(){
	int k,n;cin>>n>>k;
	vi sol(k);
	rep(k)cin>>sol[i];
	int tows = n*2;
	int fours = n;
	bool ch =0;
	int ans =0;
	rep(k){
		int a = sol[i]/8;
		fours -=a*2;
		if(fours<0){tows+=fours*2;fours=0;}
		a = sol[i]%8;
		// cout<<fours<<endl<<tows<<endl;
		if(a==6){
			if(fours>0&&tows>0){
				fours--;
				if(ch){
					ans--;
					ch = ans;
				}
				else
					tows--;
			}
			else if(fours>0){
				fours-=2;
				ans++;
				ch = true;
			}
			else if(tows>0){
				tows-=3;
			}
			else{
				cout<<"no"<<endl;
				return;
			}

		}
		else if(a==5){
			if(fours>0&&tows>0){
				fours--;
				if (ch){
					ans--;
					ch = ans;
				}
				else
				tows--;
			}
			else if(fours>0){
				fours-=2;
				ans++;
				ch = true;
			}
			else if(tows>0){
				tows-=3;
				if (ch){
					ans--;
					ch = ans;
					tows++;
				}
			}
			else{
				cout<<"no"<<endl;
				return;
			}

		}
		else if(a==4){
			if(fours>0){
				fours--;
			}
			else if(tows>0){
				tows-=2;
			}
			else{
				cout<<"no"<<endl;
				return;
			}

		}
		else if(a==3){
			if(fours>0){
				fours--;
			}
			else if(tows>0){
				tows-=2;
				if (ch){
					ans--;
					ch = ans;
					tows++;
				}
			}
			else{
				cout<<"no"<<endl;
				return;
			}

		}
		else if(a==2){
			if(tows>0){
				tows--;
			}
			else if(fours>0){
				fours--;
				ans++;
				ch = true;
			}
			else{
				cout<<"no"<<endl;
				return;
			}

		}
		else if(a==1){
			if(ch){
				ans--;
				ch = ans;
			}
			else if(fours>0){
				fours--;
				tows++;
			}
			else if(tows>0){
				tows--;
			}
			else{
				cout<<"no"<<endl;
				return;
			}
		}
		else if(a==7){

			if(fours>1){
				fours-=2;
			}
			else if(fours>0&&tows>0){
				fours--;
				tows-=2;
			}
			else if(tows>0){
				tows-=4;
				if(ch){
					ans--;
					ch=ans;
					tows++;
				}
			}
			else{
				cout<<"no"<<endl;
				return;
			}

		}

	}
	// cout<<fours<<endl<<tows<<endl;
	if(tows<0||fours<0)cout<<"no"<<endl;
	else cout<<"yes"<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	int t;cin>>t;
	while(t--){
		testCase();
	}
	// testCase();
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
#define maxn 10000+5
int a[maxn];
int fleft,tleft;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		scanf("%d",&a[i]);
	}
	fleft=n;
	tleft=n*2;
	sort(a,a+k);
	for(int i=0;i<k;i++)
	{

		while(fleft&&a[i]>=4)
		{
			a[i]-=4;
			fleft--;
		}
		while(tleft&&a[i]>=2)
		{
			a[i]-=2;
			tleft--;
		}
		if(tleft==0&&fleft==0&&a[i]!=0){puts("NO\n");return 0;}
	}
	sort(a,a+k);
	for(int i=0;i<k;i++)
	{
		if(a[i]==0)continue;
			if(a[i]<=2){
				if(tleft)
				{
					tleft--;
					a[i]=0;
				}else if (fleft)
				{
					fleft--;
					if(a[i]!=2)tleft++;
					a[i]=0;
				}
				else{puts("NO\n");return 0;}
			}
			else
			{
				if(fleft)
				{
					fleft--;
					a[i]=0;
				}
				else if(tleft>=2)
				{
					tleft-=2;
					a[i]=0;
				}
				else{puts("NO\n");return 0;}
			}
	}
	puts("YES\n");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

bool cmp(int a, int b){return a > b;}

int main(){
	int n,k,i,j;
	scanf("%d %d",&n,&k);

	int a[110];
	for(i=0;i<k;i++){
		scanf("%d",&a[i]);
	}

	int sisa4 = n, sisa2 = 2*n;
	for(i=0;i<k;i++){
		if(a[i] >= 4){
			while(a[i] >= 4){
				if(sisa4){
					sisa4--;
					a[i] -= 4;
				}else if(sisa2 >= 2){
					sisa2-=2; a[i]-=4;
				}else{
					printf("NO\n"); return 0;
				}
			}
		}
	}

	for(i=0;i<k;i++){
		if(a[i] == 3) {
			if(sisa4){
				a[i] = 0;
				sisa4--;
			}else if(sisa2>=2){
				sisa2 -= 2;
				a[i] = 0;
			}else{
				printf("NO\n"); return 0;
			}
		}
	}

	int slot1=0;

	for(i=0;i<k;i++){
		if(a[i] == 2){
			if(sisa2){
				a[i] = 0;
				sisa2--;
			} else if(sisa4) {
				slot1++;
				sisa4--;
				a[i] = 0;
			} else{
				printf("NO\n"); return 0;
			}
		}
	}
	slot1 += sisa4*2;
	for(i=0;i<k;i++){
		if(a[i] == 1){
			if(sisa2){
				a[i]--;
				sisa2--;
			}else if(slot1){
				slot1--;
				a[i]--;
			} else{
				printf("NO\n"); return 0;
			}
		}
	}
	printf("YES\n");

	return 0;
};

#include<cstdio>
#include<algorithm>
using namespace std;
int i,tem,n,k,a;
int main(){
    scanf("%d%d",&n,&k);tem=0;
    for (i=1;i<=k;i++){
    scanf("%d",&a);
    if (a%2)a++;
    tem+=a;
    }
    if (tem<=8*n)puts("YES");
    else puts("NO");
    return 0;
}

#include <iostream>
using namespace std;

int main(){
    long long n, k, even = 0, odd = 0, total = 0;
    long long a[10000];
    long long jumlah1 = 0;
    //long long plane[10001][8];
    cin>>n>>k;
    for(int i = 0; i < k; i++){
        cin>>a[i];
        if(a[i] == 1){
            jumlah1++;
        }
        total += a[i];
        if(a[i]%2 == 0){
            even++;
        }else{
            odd++;
        }
    }
    double limit = k;
    limit = limit/n;
    //cout<<limit<<endl;
    if(total + odd <= (8*n) /*&& ((limit <= 3)&&!(jumlah1 >= 4))*/){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>
#include <cstdlib>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI 3.1415926535897932
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
int a[10010];

int main()
{
    int n, k;
    cin >> n >> k;
    int four = n, two = n * 2, left1 = 0, left2 = 0;
    for(int i = 0; i < k; i++){
        scanf("%d", &a[i]);
        while(four > 0 && a[i] >= 4){
            a[i] -= 4;
            four--;
        }
        left2 += a[i] / 2;
        left1 += a[i] % 2;
    }
    while(four && left2 && left1){
        four--;
        left2--;
        left1--;
    }
    while(four && left2){
        four--;
        left2--;
    }
    while(four && left1){
        four--;
        left1 -= 2;
    }
    while(two > 0 && left1){
        two--;
        left1--;
    }
    while(two > 0 && left2){
        two--;
        left2--;
    }
    if(left2 || left1)puts("NO");
    else puts("YES");
    return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int n, k;
const int MAXK = 105;
int group[MAXK];
int leftover[8];

int main()
{
	cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> group[i];
		n -= group[i] / 8;
		group[i] %= 8;
		leftover[group[i]]++;
	}
	n -= leftover[7];

	for (int i = 6; i >= 3; i--)
	{
		if (i == 6 || i == 5)
		{
			n -= leftover[i];
			while (leftover[2] > 0 && leftover[i] > 0)
			{
				leftover[2] -= 1;
				leftover[i]--;
			}
			while (leftover[1] > 0 && leftover[i] > 0)
			{
				leftover[1] -= 1;
				leftover[1]--;
			}
		}
		if (i == 4 || i == 3)
		{
			int temp = leftover[i];
			while (leftover[2] > 0 && leftover[i] > 0)
			{
				leftover[2] -= 2;
				leftover[i]--;
			}
			while (leftover[1] > 0 && leftover[i] > 0)
			{
				leftover[1] -= 2;
				leftover[1]--;
			}
			n -= (temp - leftover[i]);
			if (leftover[i] > 0)
				n -= (leftover[i] + 1) / 2;
		}
	}

	if (leftover[2] > 0)
	{
		n -= (leftover[2] + 2) / 3;
		leftover[1] -= leftover[2] / 3;
		leftover[2] %= 3;
		if (leftover[2] == 2)
			leftover[1] -= 2;
		else if (leftover[2] == 1)
			leftover[1] -= 3;
	}
	if (leftover[1] > 0)
		n -= (leftover[1] + 3) / 4;

	if (n >= 0)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int row[3], cnt[3];

int main() {
    int n, k, cnt1 = 0;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0, a; i < k; i++) {
        cin >> a;
        if (a >= 4)
            for (; a >= 4; a -= 4) {
                if (row[1] < n) ++row[1];
                else if (row[0] < n) ++row[0];
                else ++row[2];
            }
        cnt[a]++;
    }
    for (int i = 0; i < cnt[3]; i++)
        if (row[1] < n) ++row[1];
        else if (row[0] < n - 2) row[0] += 2;
        else if (row[2] < n - 2) row[2] += 2;
        else ++row[0], ++row[2];
    for (int i = 0; i < cnt[2]; i++)
        if (row[0] < n) row[0]++;
        else if (row[2] < n) row[2]++;
        else if (row[1] < n) row[1]++, cnt1++;
        else cnt[1] += 2;
    if (row[0] <= n && row[1] <= n && row[2] <= n &&
            cnt[1] > cnt1 + n - row[0] + n - row[2] + (n - row[1]) * 2)
        cout << "no";
    else
        cout << "yes";
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define iP pair<int,int>
int power(int x,int y){
    int res=1;
    //x=x%mod;
    while(y>0){
        if(y&1)res=(res*x);
        x=(x*x);
        y/=2;
    }
    return res;
}
int mulmod(int a,int b){
    int res=0;
    a=a%mod;
    while(b>0){
        if(b%2==1)
        res=(res+a)%mod;
        a=(a*2)%mod;
        b/=2;
    }
    return res%mod;
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int twos=2*n,fours=n,ones=0;
    vector<int> v(k);
    bool flag=1;
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        int k=x/4;
        if(fours>=k){fours-=k;x-=4*k;}
        else {x-=4*fours;fours=0;}
        k=x/2;
        if(twos>=k){
            int ctr=(x&1)?1:0;
            if(ctr&&twos>=k+1){twos=twos-k-ctr;x=0;}
            else {twos-=k;x-=2*k;}
        }
        else {x-=2*twos;twos=0;}
        if(x){
            if(fours){
                if(x==3){x=0;fours-=1;}
                else if(x==2){x=0;fours-=1;ones+=1;}
                else if(x==1){x=0;fours-=1;twos+=1;}
            }
            else if(ones){
                if(x<=ones){x=0;ones-=x;}
            }
        }
        if(x){
            // cout<<i<<" ";
        flag=0;
        }
        // cout<<"#"<<fours<<" "<<twos<<" "<<ones<<"\n";
    }
    if(!flag)cout<<"NO";
    else cout<<"YES";
}

#include<bits/stdc++.h>
using namespace std;

//tipe
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef vector<LL> VLL;
typedef vector<string> VS;

//op
#define FI first
#define SE second
#define mp make_pair
#define pb push_back
#define p push

//lalala
#define all(v) v.begin(),v.end()
#define sortv(v) sort(all(v))
#define reversev(v) reverse(all(v))
#define SZ(v) ((int) v.size())
#define len(s) ((int)s.length())
#define not_emp(v) (!(bool)v.empty())
#define to(i,a,b) for(int i = a; i<=b;i++)
#define downto(i,a,b) for (int i = a; i>=b;i--)
#define each(i,v) for (int i = 0 ;i<v.size();i++)
#define set0(v) memset(v, 0, sizeof v)
#define geti(x) int x; cin>>x

//debug especialy for diyes
#define BUG(x) cout<<">> "<<#x<<" = "<<x<<endl;

//const
double const pi = acos(-1);

int c[10005],r,rr;

int main(){
	geti(r); geti(n);
	int tot =0, ganjil=0,genap=0;
	to(i,0,n-1){
		geti(x);
		c[x]++;
	}
	rr = r;
	rr<<=1;
	downto(i,10000,3){
		while(c[i]){
			if(r==0) break;
			c[i]--;
			if(i-4>=0)c[i-4]++;
			r--;
		}
	}
	int satu=0,dua=0;
	downto(i,2,1){
		while(c[i]){
			if(r==0) break;
			c[i]--;
			satu++;
			r--;
		}
	}

	downto(i,1,1){
		while(c[i]){
			if(satu==0) break;
			c[i]--;
			satu--;
		}
	}
	downto(i,1,1){
		while(c[i]){
			if(r==0) break;
			c[i]--;
			r--;
		}
	}

	dua = rr+r;
	downto(i,10000,1){
		dua-=((i+1)/2)*c[i];
	}

	if(dua<0) printf("NO\n");
	else printf("YES\n");

	return 0;
}

//
// Created by 唐律 on 2017/11/15.
//
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int sum = 0;
    int a[105];
    for (int i = 1; i <= k; i++)
        scanf("%d", &a[i]);

    int four = n;
    int two = n * 2;

    for (int i = 1; i <= k; i++) {
        if (a[i] >= 3)//在第一轮中，我们把所有大于3的情况先筛选出来
        {
            int temp4 = a[i] / 4;//当前的a[i]需要几个4排连坐
            if (temp4 <= four) //我们目前剩余的4排座位还够
            {
                four = four - temp4;
                a[i] = a[i] - temp4 * 4;//把这些人安排4个位置后还剩下多少
                if (a[i] == 3)//如果还剩下三个
                {
                    if (four >= 1)//优先分配4座连的
                    {
                        a[i] = 0;
                        four--;
                    }
                    else if (four < 1)//4座连的位置不够了，只有分配两座
                    {
                        if (two >= 2) {
                            a[i] = 0;
                            two = two - 2;
                        } else {
                            printf("NO\n");
                            return 0;
                        }
                    }
                }
            }

            else if (four < temp4)//4排的位置不够了
            {
                a[i] = a[i] - four * 4;
                four = 0;
                int temp2 = a[i] / 2;
                a[i] = a[i] - temp2 * 2;
                if (temp2 <= two) {
                    two = two - temp2;
                }
                else if (temp2 > two) {
                    printf("NO\n");
                    return 0;
                }
            }
        }
    }
    //经过我们的第一轮之后，我们所有组未分配的人数只有三种情况:0,1,2.
    int four1 = four;
    int total_four = four;
    for (int i = 1; i <= k; i++) {
        if (a[i] == 2) {
            if (four1 <= 0 && two <= 0 && four <= 0) {
                printf("NO\n");
                return 0;
            }

            if( two > 0 )
            {
                two--;
                a[i] = 0;
                continue;
            }

            if( four1 > 0 ) //我们这里安排两个人的时候，由于我们其实可以安排中间的话，我们可以安排一个1个人，但是我们只能安排一次2个人
            {
                a[i] = 0;
                four1--;
                total_four--;
                continue;
            }

            if( four > 0)
            {
                a[i] = 1;
                four--;
                continue;
            }
        }
    }
    int one = 0;
    for( int i = 1; i <= k; i++)
    {
        if(a[i] == 1 )
            one++;
    }

    sum = four+ two+total_four*2;
    if(sum < one)
    {
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
}

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int ans4 = n, ans2 = n * 2;
	int i = 0;
	int q1 = 0;
	int sum4 = 0, sum2 = 0, sum1 = 0;
	for (i = 0; i < k; i++) {
		scanf("%d", &q1);
		sum4 += (q1 / 4);
		sum2 += ((q1 % 4) / 2);
		sum1 += ((q1 % 4) % 2) ;
	}
	if (sum4 > ans4) {
		sum4 -= ans4;
		ans4 = 0;
		sum2 += (sum4 * 2);
		sum2 += sum1;
		if (ans2 < sum2)printf("NO\n");
		else printf("YES\n");
	}
	else {
		if (sum2 > ans2) {
			sum2 -= ans2;
			ans2 = 0;
			ans4 -= sum4;
			if (ans4 >= sum2 && ans4 >= sum1)printf("YES\n");
			else if (ans4>=((sum2-ans4)*2+sum1))printf("YES\n");
			else printf("NO\n");
		}
		else {
			ans4 -= sum4;
			ans2 -= sum2;
			if (ans4 * 2 +ans2>= sum1)printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}

#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int n,m,s4,s2,x,sum,s3;
int main()
{
    while(scanf("%d%d",&m,&n)!=EOF)
    {
        s4=0;
        s2=0;
        s3=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&x);
            s4+=(x/4);
            x%=4;
            if(x<=2)
                s2++;
            else
                s3++;
        }
        int ans1=m-s3;
        int ans2=m*2-s2;
        int sum=ans2+ans1*2;
        if(ans1<0||ans2<0||(sum<(s4*2)))
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

//This disgusting code is wriiten by Juruo D0zingbear
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ｌｌｄ
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=105;
int a[Maxn];
int main(){
	int n,k;
	cin>>n>>k;
	int rem2=2*n,rem4=n;
	int use=0;
	for (int i=0;i<k;i++){
		cin>>a[i];
		int xxx=min(rem4,a[i]/4);
		a[i]-=xxx*4;
		rem4-=xxx;
		if (a[i]>=2){
			rem2-=(a[i]/2);
			a[i]%=2;
		}
	}
	cout<<rem4<<' '<<rem2<<endl;
	if (rem2<0){
		if (-rem2>rem4){
			printf("NO\n");
			return 0;
		}
	}
	int ttt=rem2+2*rem4;
	for (int i=0;i<k;i++) if (a[i]==1) ttt--;
	if (ttt<0){
		cout<<"NO"<<endl;
	}
	else cout<<"YES"<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define random(a,b) ((a)+rand()%((b)-(a)+1))
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int mod=1000000007,maxn=250;
int a[maxn];
int n,k;
bool mcmp(int x,int y) { return a[x]<a[y]; }
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;
    rep(i,1,k+1) cin>>a[i];
    int mid_left=n;
    for(int i=1;i<=k&&mid_left;++i){
        int to_sit=min(mid_left,a[i]/4);
        a[i]-=to_sit*4; mid_left-=to_sit;
    }
    int ts_left=2*n;
    for(int i=1;i<=k&&ts_left;++i){
        int to_sit=min(ts_left,a[i]/2);
        a[i]-=to_sit*2; ts_left-=to_sit;
    }
    vi tmp;
    rep(i,1,k+1 ) if(a[i]) tmp.pb(i);
    sort(all(tmp),mcmp); int add=0;
    for(int i=sz(tmp)-1;i>=0&&(mid_left||add);--i){
        int pos=tmp[i];
        if(a[pos]==3) { a[pos]=0; mid_left--; }
        if(a[pos]==2) { add++; a[pos]=0;mid_left--;}
        if(a[pos]==1) { if(add) add--; else {add++;mid_left--;}  a[pos]=0; }
    }
    for(int i=sz(tmp)-1;i>=0&&(ts_left||add);--i){
        int pos=tmp[i];
        if(a[pos]==0) continue;
        int to_sit=min(ts_left,(a[pos]+1)/2);
        a[pos]-=min(to_sit*2,a[pos]);  ts_left-=to_sit;
    }
    rep(i,1,k+1) {
        if(a[i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1000;
ll a[maxn][maxn];

int main()
{

    ll n,k,i,t,j,g,sum1=0,sum2=0,sum3=0;
    scanf("%lld%lld",&n,&k);
    for(i=0;i<k;i++)
    {

        scanf("%lld",&t);
        if(t>=2)
        {
            sum2++;
            t-=2;
        }
        if(t>=1)
        {
            sum1++;
            t--;
        }
if(t>=4)
        {
            sum3+=t/4;
            t=t-(t/4)*4;
        }
    }
g=n*8-sum3*4-sum2*2-sum1*2;

    if(g>=0&&sum3+sum1>=n-g)
        printf("YES\n");

    else
        printf("NO\n");

}

// header {{{
// #define NDEBUG
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)        (abs((a)-(b)) < EPS)
#define CILING(a, b)    (((a)+(b)-1LL)/(b))

template<class T>
using PIT = pair<int, T>;
template<class T>
using PTI = pair<T, int>;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using LL  = long long;
using ULL = unsigned long long;
// }}}

int main() {
    int n, k;cin >> n >> k;
    int s, t, u;
    s = 2*n;
    t = u = n;
    vector<int> a(k);
    for(auto &aa : a) cin >> aa;
    for(int i=0;i<k;i++){
        while(a[i] >= 4 && t > 0 && u > 0){
            t--;
            u--;
            a[i]-=4;
        }
    }
    for(int i=0;i<k;i++){
        while(a[i] >= 3 && t > 0 && u > 0){
            t--;
            u--;
            a[i]-=3;
        }
    }
    for(int i=0;i<k;i++){
        while(a[i] >= 2 && s > 0){
            s--;
            a[i]-=2;
        }
    }
    for(int i=0;i<k;i++){
        while(a[i] >= 2 && t > 0){
            t--;
            a[i]-=2;
        }
        if(a[i] >= 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    for(int i=0;i<k;i++){
        if(a[i] == 0) continue;
        if(s > 0){
            s--;
            a[i]--;
        }else if(t > 0){
            t--;
            a[i]--;
        }else if(u > 0){
            u--;
            a[i]--;
        }
        if(a[i] == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

#include <iostream>
#include <vector>

using namespace std;

/***********
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}.

Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.

Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.

Input
The first line contains two integers n and k (1 ≤ n ≤ 10000, 1 ≤ k ≤ 100) — the number of rows and the number of groups of soldiers, respectively.

The second line contains k integers a1, a2, a3, ..., ak (1 ≤ ai ≤ 10000), where ai denotes the number of soldiers in the i-th group.

It is guaranteed that a1 + a2 + ... + ak ≤ 8·n.

Output
If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes).

You can choose the case (lower or upper) for each letter arbitrary.
***********/

int main()
{
	vector<int> seats(5, 0);
	int rows, groups;
	cin >> rows >> groups;
	//buliding seats map
	seats.at(2) = rows * 2;
	seats.at(4) = rows;
	bool flag(0);
	int people;
	//distribute seats to each group
	for (int index(0); index < groups; ++index)
	{
		cin >> people;
		for (int i(4); i > 0; --i)
		{
			//cout << "The " << i << "th round of groups " << index << "."<< endl;
			if (seats.at(i) > 0 && people > 0)
			{
				int q(0);
				int r(0);
				q = people / i;
				r = people % i;
				//cout << "q: " << q << " r: " << r << endl;
				if (q > seats.at(i))
				{
					people = (q - seats.at(i)) * i + r;
					seats.at(i) = 0;
				}
				else
				{
					seats.at(i) -= q;
					people -= i * q;
					for (int j = i; j > 0; --j)
					{
						while (seats.at(j) > 0 && j > r && people > 0)
						{
							--(seats.at(j));
							++(seats.at(i - r - 1));
							people -= j;
						}
					}
					//cout << "Rest people: "<< people << endl;
					//cout << "0 1 2 3 4" << endl;
					/*for (auto iter = seats.begin(); iter != seats.end(); ++iter)
					{
						cout << *iter << " ";
					}
					cout << endl;*/
				}
			}
		}
		if (people > 0)
		{
			cout << "NO" << endl;
			flag = 1;
			break;
		}
	}

	if (flag == 0)
	{
		cout << "YES" << endl;
	}
	//test
	/*for (auto iter = seats.begin(); iter != seats.end(); ++iter)
	{
		cout << *iter << " ";
	}
	cout << endl;*/
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,k,q;
int rec[10001],fil[101][9];
bool pd(){
	for (int i=1;i<=n;i++)
		if (rec[i]>0)	return false;
	return true;
}
bool cmp(int x,int y){
	return x>y;
}
bool findo(int x){
	for (int i1=x;i1<=n;i1++)
		if (rec[i1]==1)	return 1;
	return 0;
}
int main(){
	scanf("%d%d",&k,&n);

	for (int i=1;i<=n;i++)
		scanf("%d",rec+i);
	sort(rec+1,rec+1+n,cmp);
	int z=0;
	for (int i=1;i<=n;i++)
		if (z<k)
		if (rec[i]/4>0){
			int p=rec[i]/4;
			if (p<=k-z){
			rec[i]-=p*4;
			z+=p;
			}else{
				rec[i]-=4*(k-z);
				z=k+1;
			}
		}
	sort(rec+1,rec+1+n,cmp);
	for (int i=1;i<=n;i++)
		if (z<k)
		if (rec[i]/3>0){
			int p=rec[i]/3;
			if (p<=k-z){
			rec[i]-=p*3;
			z+=p;
			}else{
				rec[i]-=3*(k-z);
				z=k+1;
			}
		}
	sort(rec+1,rec+1+n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (z<k){
				if (rec[i]==1&&rec[j]==2&&i!=j){
					z++;
					rec[i]=rec[j]=0;
				}
				if (rec[i]==1&&rec[j]==1&&i!=j){
					z++;
					rec[i]=rec[j]=0;
				}
			}
	for (int i=1;i<=n;i++)
			if (z<k){
				if (rec[i]==2){
					z++;
					rec[i]=0;
				}
				if (rec[i]==1){
					z++;
					rec[i]=0;
				}
			}
	if (pd()==1){
		printf("YES\n");
		exit(0);
	}
	sort(rec+1,rec+1+n,cmp);
	k*=2;
	z=0;
	for (int i=1;i<=n;i++)
		{
			if (rec[i]%2==1)
				{
					z+=rec[i]/2+1;
					rec[i]=0;
				}
			else{
				z+=rec[i]/2;
				rec[i]=0;
			}
			if (z>=k)	break;
		}
	if (pd())	printf("YES\n"); else printf("NO\n");
	return 0;
}

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 100100
const ll inf = std::numeric_limits<ll>::max();
const ll mod = 1e9+7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[nmax];
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin >> n >> k;
    n*=8;
    fo(i,0,k){
        int x;
        cin >> x;
        n -= x-x%4;
        x%=4;
        if(x==1 || x==2) n-=2;
        if(x==3) n-=4;
        if(n <0) return cout << "NO",0;
    }
    cout << "YES";
    return 0;
}

#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

const int MAXN = 10000 + 5;

int gt[MAXN];

bool toCheck(int t, int f, int k)
{
	int single = 0, duble = 0;
	for (int i = 1;i <= k;++i)
	{
		if (gt[i] / 4 >= 1)
		{
			if (f >= gt[i]/4)
				f -= gt[i] / 4;
			else
				duble += (gt[i] - 4 * f) / 2, f = 0;
		}
		int left = gt[i] % 4;
		if (left == 0) continue;
		if (left == 3)
			single++, duble++;
		else if (left == 2) duble++;
		else single++;
	}
	if (t >= duble)
	{
		t -= duble;
		duble = 0;
		if (t + f * 2 >= single) return true;
		else return false;
	}
	else
	{
		duble -= t;
		t = 0;
		if (duble > f)
		{
			single += (duble - f) * 2;
			if (single > f) return false;
		}
		else
		{
			single -= duble;
			f -= duble;
			if (single > f * 2) return false;
		}
	}
	return true;
}

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	int two = n * 2, four = n;
	for (int i = 1;i <= k;++i)
		scanf("%d", &gt[i]);
	if (toCheck(two, four, k))
		puts("YES");
	else
		puts("NO");
	return 0;
}

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
const int mod=1e9+7;
int a[10000+10],sum_1,sum_4,sum_2;
bool cal_4(int n)
{
    if(!n) return 1;
    int tmp=n/4;
    if(sum_4>=tmp)  sum_4-=tmp;
    else
    {
        n-=sum_4*4,sum_4=0;
        if(n%2==0)
        {
            tmp=n/2;
            if(sum_2>=tmp) sum_2-=tmp;
            else
            {
                n-=sum_2*2,sum_2=0;
                if(n>=sum_1) sum_1-=n;
                else return 0;
            }
        }
        else if(n%2==1)
        {
            tmp=n/2;
            if(sum_2>=tmp)
            {
                sum_2-=tmp;
                if(sum_1>=1) sum_1-=1;
                else
                {
                    if(sum_2>=1) sum_2-=1;
                    else return 0;
                }
            }
            else
            {
                n-=sum_2*2;
                if(sum_1>=n) sum_1-=n;
                else return 0;
            }
        }
    }
    return 1;
}
bool cal_1()
{
    if(sum_1>=1)
    {
        sum_1-=1;
        return 1;
    }
    if(sum_2>=1)
    {
        sum_2-=1;
        return 1;
    }
    if(sum_4>=1)
    {
        sum_4-=1;
        sum_2+=1;
        return 1;
    }
    return 0;
}
bool cal_2()
{
    if(sum_1>=2)
    {
        sum_1-=2;
        return 1;
    }
    if(sum_2>=1)
    {
        sum_2-=1;
        return 1;
    }
    if(sum_4>=1)
    {
        sum_4-=1;
        sum_1+=1;
        return 1;
    }
    return 0;
}
bool cal_3()
{
    if(sum_1>=3)
    {
        sum_1-=3;
        return 1;
    }
    if(sum_1>=1)
    {
        sum_1-=1;
        return cal_2();
    }
    if(sum_2>=1)
    {
        sum_2-=1;
        return cal_1();
    }
    if(sum_4>=1)
    {
        sum_4-=1;
        return 1;
    }
    return 0;
}
int solve(int n,int k) //n排，k组
{
    int i;
    for(i=1; i<=k; i++)
    {
        if(sum_1>=a[i])
        {
            sum_1-=a[i];
            continue;
        }
        else a[i]-=sum_1,sum_1=0;

        if(sum_2*2>=a[i])
        {
            sum_2-=(a[i]/2+a[i]&1);
            continue;
        }
        else a[i]-=sum_2*2,sum_2=0;

        int tmp=a[i]%4;
        if(!cal_4(a[i]/4*4)) return 0;
        if(tmp==1)
        {
            if(!cal_1())
                return 0;
        }
        if(tmp==2)
        {
            if(!cal_2())
                return 0;
        }
        if(tmp==3)
        {
            if(!cal_3())
                return 0;
        }
    }
    return 1;
}
int main()
{
    int n,k,i;
    scanf("%d%d",&n,&k);
    for(i=1; i<=k; i++)
        scanf("%d",&a[i]);
    sum_4=n,sum_1=0,sum_2=n*2;
    printf(solve(n,k)?"YES\n":"NO\n");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int MAXN = 1e4+7;
const int inf = 1e9;
int n,k;
int num[MAXN];

int main()
{
    scanf("%d%d",&n,&k);
    //x1表示４连座，x2表示２连座，x3表示４连座已经坐了两个了（还能坐１个的）
    int x1 = n,x2 = n*2,x3 = 0;
    int x;
    for(int i = 0; i < k; ++i)scanf("%d",&num[i]);
    sort(num,num+k);
    for(int i = 0; i < k; ++i)
    {
        x = num[i];
        if(x1)//如果还有４个座位的
        {
            int d = x/4;//先坐４个座位的
            if(x1 >= d)//如果都能坐上去
            {
                x1 -= d;//坐上去
                if(x % 4 == 3)//剩下３个
                {
                    if(x3&&x2)x3--,x2--;
                    else if(x1)x1--;
                    else if(x2>=2)x2-=2;
                    else x3-=3;
                }
                else if(x%4 == 2)//剩下２个
                {
                    if(x2)x2--;
                    else if(x3 >= 2)x3-=2;
                    else x1--,x3++;
                }
                else if(x%4==1)//剩下１个
                {
                    if(x3)x3--;
                    else if(x2)x2--;
                    else x1--,x2++;
                }
            }
            else//如果不能全部坐上去
            {
                x -= x1*4;//那么就先坐上１部分
                x1 = 0;
                int d2 = x/2;
                if(x2 >= d2)//２连座全部能坐上
                {
                    x2 -= d2;
                    if(x%2)//如果还有剩余
                    {
                        if(x3)x3--;
                        else x2--;
                    }
                }
                else//如果２连座不能全坐上
                {
                    x -= x2*2;//坐一部分
                    x2 = 0;
                    x3 -= x;
                }
            }
        }
        else //没有４个座位的了
        {
            int d2 = x/2;
            if(x2 >= d2)//２连座全部能坐上
            {
                x2 -= d2;
                if(x%2)//如果还有剩余
                {
                    if(x3)x3--;
                    else x2--;
                }
            }
            else//如果２连座不能全坐上
            {
                x -= x2*2;//坐一部分
                x2 = 0;
                x3 -= x;
            }
        }
        if(x1 <0 || x2<0 || x3 < 0) return 0*puts("NO");
    }
    puts("YES");
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int n,k,a[101],nn,j,l;

int main()
{
	scanf("%d%d",&n,&k); nn=n;
	for (int i=1; i<=k; i++) scanf("%d",&a[i]);
	for (int i=1; i<=k; i++)
		while (a[i]>=4) nn--,a[i]-=4;
	if (nn<=0)
	{
		nn=n*2+2*nn;
		for (int i=1; i<=k; i++)
			nn-=(a[i]+1)/2;
		if (nn<0) {printf("NO"); return 0;}
		else {printf("YES"); return 0;}
	}
	sort(a+1,a+1+n);
	j=k;
	while (a[j]==3) nn--,a[j]=0,j--;
	if (nn<=0)
	{
		nn=2*n+2*nn;
		for (int i=1; i<=k; i++)
			nn-=(a[i]+1)/2;
		if (nn<0) {printf("NO"); return 0;}
		else {printf("YES"); return 0;}
	}
	l=1; a[0]=0;
	while (a[l]==0) l++;
	while (a[j]==2)
	{
		nn--,a[j]=0,j--;
		if (a[l]==1) l++;
	}
	if (a[l]!=1)
	{
		if (0>nn+2*n) printf("NO"); else printf("YES");
		return 0;
	}
	nn+=2*n;
	while (nn&&a[l]==1) nn--,l++;
	if (a[l]!=1) printf("YES"); else printf("NO");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;

#define REP(i, a, b) \
    for (int i = (a); i < (b); i++)
#define TRvi(c, it) \
    for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
    for (vii::iterator it = (c).begin(); it != (c).end(); it++)

#define INF 2000000000 // 2e9
#define INFLL 2000000000000000000 // 2e18

inline ll GCD(ll a, ll b) {while (b != 0) {ll c = a % b; a = b; b = c;} return a;};
inline ll LCM(ll a, ll b) {return (a / GCD(a,b)) * b;};

int main()
{
    int n, k;
    cin >> n >> k;
    int numrow = 1, numseat = 0;
    vi arr;
    REP(i, 0, k) {
        int x;
        cin >> x;
        arr.push_back(x);
    }
    sort(arr.rbegin(), arr.rend());
    REP(i, 0, k) {
        int x = arr[i];
        if (numseat == 1) numseat = 2;
        else if (numseat == 3) numseat = 4;
        else if (numseat == 5) numseat = 6;
        else if (numseat == 6) numseat = 7;
        else if (numseat == 7) {
            numseat = 0;
            numrow++;
        }
        while (x-- > 0) {
            numseat++;
            if (numseat >= 8) {
                numseat = 0;
                numrow++;
            }
        }
    }
    if (numseat == 0) numrow--;
    if (numrow <= n) cout << "YES" << endl;
    else cout << "NO" << endl;
    //cout << numrow;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k, ans=0;
  cin >> n >> k;
  for (int i=0; i<k; i++) {
    int x;
    cin >> x;
    ans += x;
    if (i != (k-1)) {
      int num = k%8;
      if (num == 1 || (num >= 3 && num <=5) || num == 7)
	ans++;
    }
  }
  if (ans <= (n*8))
    cout << "YES\n";
  else
    cout << "NO\n";
}

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define INF 1e8
#define pr 998244353
#define endl "\n"
//#define ordered_set tree<pair<int,int>, nuint_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>

int power(int x,int y)
{
    if(y==0)return 1;
    if(y%2)return (x%MOD * power(x,y-1)%MOD)%MOD;
    else return power((x*x)%MOD,y/2)%MOD;
}

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  int n,k;
  cin>>n>>k;
  int arr[k];
  int cnt=0;
  int sum=0;

  for(int i=0;i<k;i++){
  	cin>>arr[i];
  	cnt+=arr[i]/4;
  	arr[i]%=4;
  	if(arr[i]==0){
  		arr[i]=4;
  		cnt--;
  	}
  }

  sort(arr,arr+k);
  reverse(arr,arr+k);

  if(cnt>n){
  	cout<<"NO";
  	return 0;
  }
 int i=0;
 while(cnt<n && i<k)
 {
 	if(arr[i]>=3)cnt++;
 	else break;
 	i++;
 }

 int cnt1=0;
 while(cnt1<cnt && i<k)
 {
 	if(arr[i]>=3)cnt1++;
 	else {
 		cnt1++;
 		i++;
 	}
 	i++;
 }

 if(arr[i]>=3){
 	cout<<"NO";
 	return 0;
 }

int x=0;
while(i<k)
{
	x=0;
	cnt++;
 while(i<k && x+arr[i]<8)
 {
 	x+=arr[i];
 	i++;
 }

}

if(cnt>n)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
//cout<<cnt<<endl;

}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);

    int inp[k];
    int four = n;

    for (int i = 0; i < k; i++) {
        scanf("%d", &inp[i]);

        int tmp = inp[i] / 4; // no. of group of 4

        int toSub = min(four, tmp);
        four -= toSub;
        inp[i] -= toSub * 4;
    }

    int two = n * 2;

    if (four == 0) {
        for (int i = 0; i < k; i++)
            two -= (inp[i] + 1) / 2;
    } else {
        for (int i = 0; i < k; i++) {
            if (inp[i] == 3) {
                if (four > 0)
                    four--;
                else
                    two -= 2;

                inp[i] = 0;
            }
        }

        // printf("%d\n", four);
        two += four * 2;
        for (int i = 0; i < k; i++) {
            if (inp[i] > 0)
				two -= (inp[i] + 1) / 2;
        }
    }

    if (two >= 0)
        puts("YES");
    else
        puts("NO");

    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <fstream>
#include <map>
#include <set>
#include <queue>
#include <memory.h>

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PI;
typedef vector<PI> VPI;

#define FOR(i,a,n) for (int i = (a); i < (n); ++i)
#define FORE(i,a,n) for (int i = (a); i <= (n); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FORE(i,0,n)
#define LL long long
#define FIR(n) REP(i,n)
#define FJR(n) REP(j,n)
#define ALL(v) v.begin(), v.end()

#define FI FIR(n)
#define FJ FJR(n)
#define FR(i,a) FOR(i,a,n)
#define REPN(i) REP(i,n)

#define GI(n) scanf("%d", &n)
#define GI2(n,m) scanf("%d %d", &n, &m)

int main() {
#ifdef LOCALF
	freopen("input.txt", "rt", stdin);
#endif

	int n, k;
	GI2(n, k);

	bool ok = true;
	int a;
	int t1 = 0, t2 = 2 * n, t4 = n;
	FIR(k){
		GI(a);

		int x4 = min(t4, a / 4);
		t4 -= x4;
		a -= 4 * x4;

		if (a == 3 && t4) {
			--t4;
			a = 0;
		}

		int x2 = min(t2, a / 2);
		t2 -= x2;
		a -= 2 * x2;

		if (t2 && a > 0) {
			--t2;
			--a;

		}

		if (t4 && a > 0) {

			--t4;
			if (a == 1)
				++t2;
			if (a == 2)
				++t1;
			a = 0;
		}

		int x1 = min(t1, a);
		t1 -= x1;
		a -= x1;

		if (a > 0)
			ok = false;
	}

	puts(ok ? "YES" : "NO");

}

#include<bits/stdc++.h>
using namespace std;
#define MEM(a,b) memset(a,b,sizeof(a))
#define bug puts("bug");
#define PB push_back
#define MP make_pair
#define X first
#define Y second
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+10;
using namespace std;
int n,k,a[maxn];

int main(){
    cin>>k>>n;
    ll sum=0,yu[3];
    yu[2]=yu[1]=0;
    int four=k,two=k*2;
    for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
    for(int i=0;i<n;i++){
        while(four>0&&a[i]>=4) a[i]-=4,four--;
        while(two>0&&a[i]>=2) a[i]-=2,two--;
        yu[a[i]]++;
    }
    //
    //cout<<yu[2]<<"  "<<yu[1]<<endl;
    if(yu[2]*2>four*3||yu[1]+yu[2]>two+four*2) puts("NO");
    else puts("YES");
    return 0;
}

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define ll long long
#define ull unsigned long long
#define mem(a,x) memset((a),(x),sizeof ((a)))//x只能是0或-1或false或true
#define debug(x) cout<<"X: "<<(x)<<endl
#define de cout<<"************"<<endl
#define lowbit(x) ((x)&(-x))
#define lson rt<<1
#define rson rt<<1|1
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/(__gcd(a,b))
#define inf 0x3f3f3f3f//1e9+6e7
#define eps 1e-8
#define mod 1e9+7
#define N 1000010
const double pi=acos(-1.0);
using namespace std;
int a[110];
int b[10010][10];
int main()
{
    int n,k;
    cin>>n>>k;
    rep(i,0,k-1)
        cin>>a[i];
    int f=1;
    mem(b,0);
    int p=0,q=8;
    rep(i,0,k-1)
    {
        p+=(a[i]/8);
        a[i]%=8;
    }
    //cout<<"$$"<<p<<endl;
    n-=p;
    p=0;
    q=1;
    rep(i,0,k-1)
    {
        if(q>n)
            break;
        if(a[i]==4)
        {
            if(q!=n+1)
            {
                rep(j,3,6)
                    b[q][j]=1;
                a[i]=0;
                q++;
            }
        }
    }
    int x=1,y=1;
    //cout<<"**"<<n<<endl;
    rep(i,0,k-1)
    {
        if(a[i]==0)
            continue;
        if(x>n)
            {cout<<"NO";return 0;}
        rep(j,1,a[i])
        {
            while(b[x][y]==1)
            {
                if(y==8)
                    {x++;y=1;}
                else
                    y++;
            }
            b[x][y]=1;
        }

        if(y==2||y==6||y==8)
            continue;
        else
        {
            if(y==8)
                    {x++;y=1;}
            else
                y++;
            if(y==8)
                    {x++;y=1;}
            else
                y++;
        }

    }

    cout<<"YES";

    return 0;
}

#include<conio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,k,temple=0,res;
    cin>>n>>k;
    n=8*n;
    int *ar=new int[k];
    int x=n/2,y=n/2;
    for(int i=0;i<k;i++)
    {
        ar[i]=0;
        cin>>ar[i];
        if(x>0)
        {
            if(ar[i]%2==0)
            {
                x=x-ar[i];
            }
            else
            {
                x=x-ar[i]-1;
            }
        }
        else
        {
             if(ar[i]%4==0)
            {
                x=x-ar[i]+temple;
                temple=0;
            }
             if(ar[i]%4==1)
            {
                x=x-ar[i]+temple-3;
                if(i==k-1)
                {
                    x=x+3;
                }
                temple=2;
            }
             if(ar[i]%4==2)
            {
                x=x-ar[i]+temple-2;
                if(i==k-1)
                {
                    x=x+2;
                }
                temple=1;
            }
             if(ar[i]%4==3)
            {
                x=x-ar[i]+temple-1;
                if(i==k-1)
                {
                    x=x+1;
                }
                temple=0;
            }
        }

    }
    res=x+y;
    if (res>=0)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    //getch();
    return(0);
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int a[110];
int b[10];
int main(){
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        int p=0;
        for(int i=0;i<k;i++){
            scanf("%d",&a[i]);
            n-=a[i]/8;
            a[i]=a[i]%8;
            b[2]+=a[i]/2;
            if(a[i]%2) b[1]++;
        }
        while(b[2]>2){
            if(b[1]==0) break;
            b[1]-=1;
            n--;
            b[2]-=3;
        }
        //printf("%d %d\n",b[2],b[1]);
        int sum=(b[2]+b[1])*2;
        if(sum>n*8) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

/**
  _____    _           _               _____                    _
 |  __ \  (_)         | |             |  __ \                  | |
 | |  | |  _   _ __   | |_    __ _    | |__) |   __ _   _   _  | |
 | |  | | | | | '_ \  | __|  / _` |   |  ___/   / _` | | | | | | |
 | |__| | | | | |_) | | |_  | (_| |   | |      | (_| | | |_| | | |
 |_____/  |_| | .__/   \__|  \__,_|   |_|       \__,_|  \__,_| |_|
              | |
              |_|
*/

/**
            তুমি তামাক ধরাও তামাক ধরাও
            আগুন জ্বালিয়ে দাও।
            আগুন জ্বালালে উড়ে যাবে পাখি মনা
            আগুন জ্বালালে উড়ে যাবে পাখি।

            নেশা কেটে গেলে তুমিও কেটে যাবে।
*/

#include <bits/stdc++.h>

using namespace std;

#define read                            freopen("in.txt", "r", stdin)
#define pb                              push_back
#define f                               first
#define s                               second
#define EPS                             1e-9
#define sf                              scanf
#define pf                              printf
#define si1(x)                          scanf("%d",&x)
#define si2(x,y)                        scanf("%d %d",&x,&y)
#define si3(x,y,z)                      scanf("%d %d %d",&x,&y,&z)
#define sd1(x)                          scanf("%lf",&x)
#define sd2(x,y)                        scanf("%lf %lf",&x,&y)
#define sd3(x,y,z)                      scanf("%lf %lf %lf",&x,&y,&z)
#define sl1(x)                          scanf("%lld",&x)
#define sl2(x,y)                        scanf("%lld %lld",&x,&y)
#define sl3(x,y,z)                      scanf("%lld %lld %lld",&x,&y,&z)
#define sz(x)                           (int)(x).size()
#define all(x)                          (x).begin(), (x).end()
#define rall(x)                         (x).rbegin(), (x).rend()
#define ms(x,a)                         memset(x,a,sizeof(x))
#define rep(i,a,b)                      for(int i=(a); i<(b); i++)
#define repc(i,x)                       for(int i=0; i<(sz(x)); i++)
#define repit(it,x)                     for(__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define nn                              "\n"

typedef long long int                   ll;
typedef pair<int,int>                   pii;
typedef pair<ll,ll>                     pll;
typedef vector<int>                     vi;
typedef vector<ll>                      vl;
typedef vector<string>                  vs;
typedef vector<char>                    vc;
typedef vector<bool>                    vb;
typedef vector<pii>                     vii;
typedef map<string,int>                 msi;
typedef map<int,int>                    mii;
typedef map<char,int>                   mci;
typedef map<int,string>                 mis;

template<typename T> T Abs(T x)
{
    return x>0 ? x : -x ;
}
template<typename T> T const& Max(T const& a, T const& b)
{
    return a>b ? a : b ;
}
template<typename T> T const& Min(T const& a, T const& b)
{
    return a<b ? a : b ;
}
template<typename T> inline T gcd(T a, T b)
{
    return (b ? gcd(b,a%b) : a) ;
}
template<typename T> T sqaa(T a)
{
    return a*a ;
}

///******************** SOLUTION ********************\\\

int main()
{
    #ifdef Ami_oke_Bhalobasi_ni_:D
        freopen("B.txt", "r", stdin);
        //freopen("Bout.txt", "w+", stdout);
    #endif /// Ami_oke_Bhalobasi_ni_:D

    int n, k, ar[105];

    while(cin >> n >> k) {
        for(int i=0; i<k; i++) {
            cin >> ar[i];
            n -= ar[i]/8;
            ar[i] %= 8;
        }
//        for(int i=0; i<k; i++) {
//            ar[i] %= 4;
//        }
//        for(int i=0; i<k; i++) {
//            ar[i] %= 2;
//        }
////        bool fl = 0;
////        for(int i=0; i<k; i++) {
////            if(ar[i]) {
////                fl = 1;
////                break;
////            }
////        }
////        if(!fl) {
////            cout << "YES\n";
////        }
////        else {
////            cout << "NO\n";
////        }

        int tot4 = n;
        int tot2 = n*2;

        for(int i=0; i<k; i++) {
            if(tot4) {
                tot4 -= ar[i]/4;
                ar[i] %= 4;
            }
        }

        for(int i=0; i<k; i++) {
            if(ar[i] == 3 && tot4) {
                ar[i] = 0;
                tot4--;
            }
        }

        for(int i=0; i<k; i++) {
            for(int j=0; j<k; j++) {
                if(ar[i] == 2 && ar[j] == 1 && tot4) {
                    tot4--;
                    ar[i] = ar[j] = 0;
                }
            }
        }

        for(int i=0; i<k; i++) {
            tot2 -= ar[i]/2 + ar[i] % 2;
        }

//        cout << tot2 << " " << tot4 << endl;

        if(tot2>=0 && tot4>=0) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }

    }

    return 0;
}