#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[50005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<200005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<=500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;
		if(needtwo>1){
			if(one>=num) for(int j=0;j<one;j++) ans1.push_back(1);
			one-=num;
			continue;
		}
		//cout<<needtwo<<endl;
	 	if(two>=needtwo){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
		 }else{
		 	if(one>=num){
			 for(int j=0;j<num;j++){
			 		ans1.push_back(1);
		 		}
		 		one = one-num;
			}else{
				for(int j=0;j<one;j++) ans1.push_back(1);
				for(int j=0;j<two;j++) ans1.push_back(2);
				break;
			}
		 }
	}

		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[50005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<200005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<=500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
	int o = one,t = two;
	int first = 0,second = 0;
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;
		//cout<<needtwo<<endl;
	 	if(two>=needtwo){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
			first++;
		 }else{
		 	for(int i=0;i<one;i++) ans1.push_back(1);
		 	for(int i=0;i<two;i++) ans1.push_back(2);
		 	break;
		 }
	}
//	//����1 ����2�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needone = num;
	 	if(o>=needone){
	 		for(int j=0;j<needone;j++) ans2.push_back(1);
	 		o = o-needone;
			second++;
		 }else{
		 	int needtwo = num/2;
		 	if(t>=needtwo){
		 		if(num%2==1){
		 			if(one>=1){
		 				for(int j=0;j<needtwo;j++) ans2.push_back(2);
		 				ans2.push_back(1);
		 				one--;
		 				t-=needtwo;
					 }else{
					 	break;
					 }
				 }else{
				 	t = t-needtwo;
					for(int j=0;j<needtwo;j++) ans2.push_back(2);
				 }
			 }else{
			 	for(int i=0;i<o;i++) ans1.push_back(1);
			 	for(int i=0;i<t;i++) ans1.push_back(2);
			 	break;
			 }
		 }
	}
	if(first>second){
		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}
	}else{
		int sz = ans2.size();
		for(int i=0;i<sz;i++){
			cout<<ans2[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[50005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<200005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<=500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
//	if(one==0){
//		for(int i=0;i<two;i++){
//			cout<<2;
//			if(i!=two-1) cout<<' ';
//			else cout<<endl;
//		}
//		return 0;
//	}
//	if(two==0){
//		for(int i=0;i<one;i++){
//			cout<<1;
//			if(i!=one-1) cout<<' ';
//			else cout<<endl;
//		}
//		return 0;
//	}
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;

/*
15
1 2 1 2 1 1 1 1 1 1 2 2 2 1 1
*/
		//cout<<needtwo<<endl;
	 	if(two>=needtwo&&needtwo!=0){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
		 }else{
		 	if(one>=num){
			 for(int j=0;j<num;j++){
			 		ans1.push_back(1);
		 		}
		 		one = one-num;
			}else{
				for(int j=0;j<one;j++) ans1.push_back(1);
				for(int j=0;j<two;j++) ans1.push_back(2);
				break;
			}
		 }
	}

		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[50005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<200005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<=500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;
		if(needtwo>1){
			if(one>=num){
				for(int j=0;j<one;j++) ans1.push_back(1);
				one-=num;
				continue;
			}
		}
		//cout<<needtwo<<endl;
	 	if(two>=needtwo){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
		 }else{
		 	if(one>=num){
			 for(int j=0;j<num;j++){
			 		ans1.push_back(1);
		 		}
		 		one = one-num;
			}else{
				for(int j=0;j<one;j++) ans1.push_back(1);
				for(int j=0;j<two;j++) ans1.push_back(2);
				break;
			}
		 }
	}

		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[50005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<200005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<=500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;
		if(needtwo>1){
			if(one>=num){
				for(int j=0;j<num;j++) ans1.push_back(1);
				one-=num;
				continue;
			}
		}
/*
15
1 2 1 2 1 1 1 1 1 1 2 2 2 1 1
*/
		//cout<<needtwo<<endl;
	 	if(two>=needtwo){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
		 }else{
		 	if(one>=num){
			 for(int j=0;j<num;j++){
			 		ans1.push_back(1);
		 		}
		 		one = one-num;
			}else{
				for(int j=0;j<one;j++) ans1.push_back(1);
				for(int j=0;j<two;j++) ans1.push_back(2);
				break;
			}
		 }
	}

		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[500005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<500005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
//	if(one==0){
//		for(int i=0;i<two;i++){
//			cout<<2;
//			if(i!=two-1) cout<<' ';
//			else cout<<endl;
//		}
//		return 0;
//	}
//	if(two==0){
//		for(int i=0;i<one;i++){
//			cout<<1;
//			if(i!=one-1) cout<<' ';
//			else cout<<endl;
//		}
//		return 0;
//	}
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;

/*
15
1 2 1 2 1 1 1 1 1 1 2 2 2 1 1
*/
		//cout<<needtwo<<endl;
	 	if(two>=needtwo&&needtwo!=0){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
		 }else{
		 	if(one>=num){
			 for(int j=0;j<num;j++){
			 		ans1.push_back(1);
		 		}
		 		one = one-num;
			}else{
				for(int j=0;j<one;j++) ans1.push_back(1);
				for(int j=0;j<two;j++) ans1.push_back(2);
				break;
			}
		 }
	}

		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[50005];
int vis[500005];
int cnt = 1;
vector<int>ans1,ans2;
void init(){
	for(int i=1;i<=500005;i++){
		vis[i] = 1;
	}
	for(int i=2;i<200005;i++){
		if(vis[i]){
			prime[cnt++] = i;
			for(int j=i;j<=500005;j+=i){
				vis[j] = 0;
			}
		}
	}
}
int main(){
	init();
	int n,a;
	cin>>n;
	int one=0,two=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==1) one++;
		else two++;
	}
	//����2 ����1�����
	for(int i=1;i<=cnt;i++){
		int num = prime[i]-prime[i-1];
		int needtwo = num/2;
		if(needtwo==2){
			if(one>=num&&(one/4)>(two/2)){
				for(int j=0;j<num;j++) ans1.push_back(1);
				one-=num;
				continue;
			}
		}
/*
15
1 2 1 2 1 1 1 1 1 1 2 2 2 1 1
*/
		//cout<<needtwo<<endl;
	 	if(two>=needtwo){
	 		if(num%2==1){
	 			if(one>=1){
	 				for(int j=0;j<needtwo;j++) ans1.push_back(2);
	 				ans1.push_back(1);
	 				one--;
	 				two = two-needtwo;
				}else{
					break;
				}
			}else{
				two = two-needtwo;
				for(int j=0;j<needtwo;j++) ans1.push_back(2);
			}
		 }else{
		 	if(one>=num){
			 for(int j=0;j<num;j++){
			 		ans1.push_back(1);
		 		}
		 		one = one-num;
			}else{
				for(int j=0;j<one;j++) ans1.push_back(1);
				for(int j=0;j<two;j++) ans1.push_back(2);
				break;
			}
		 }
	}

		int sz = ans1.size();
		for(int i=0;i<sz;i++){
			cout<<ans1[i];
			if(sz-1!=i) cout<<' ';
			else cout<<endl;
		}

	return 0;
}


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

bool prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<2<<" "<<1<<" ";
   for(ll i=2;i<=c1;i++) cout<<2<<" ";
   for(ll i=2;i<=c2;i++) cout<<1<<" ";
}


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

bool prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<2<<" "<<1<<" ";
   c2--;
   c1--;
   for(ll i=2;i<=c1;i++) cout<<2<<" ";
   for(ll i=2;i<=c2;i++) cout<<1<<" ";
}


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

bool prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0,sum=1;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<2<<" ";
   c2--;
   for(ll i=1;i<n;i++){
         if(prime(sum+1)&&c1>0){
             cout<<1<<" ";
             c1--;
         }
         else if(prime(sum+2)&&c2>0){
             cout<<2<<" ";
             c2--;
         }
         else{
             if(c1>=c2&&c1>0){ cout<<1<<" "; c1--;}
             else if(c2>0) {cout<<2<<" "; c2--;}
             else {cout<<1<<" "; c1--;}
         }
   }
}


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

bool prime(int n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0,sum=1;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<1<<" ";
   c1--;
   for(ll i=1;i<n;i++){
         if(prime(sum+1)&&c1>0){
             cout<<1<<" ";
             c1--;
         }
         else if(prime(sum+2)&&c2>0){
             cout<<2<<" ";
             c2--;
         }
         else{
             if(c1>=c2&&c1>0){ cout<<1<<" "; c1--;}
             else if(c2>0) {cout<<2<<" "; c2--;}
         }
   }
}


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

bool prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0,sum=1;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<2<<" ";
   c2--;
   for(ll i=1;i<n;i++){
         if(prime(sum+1)&&c1>0){
             cout<<1<<" ";
             c1--;
         }
         else if(prime(sum+2)&&c2>0){
             cout<<2<<" ";
             c2--;
         }
         else{
             if(c1>c2){ cout<<1<<" "; c1--;}
             else {cout<<2<<" "; c2--;}
         }
   }
}


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

bool prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<2<<" "<<1<<" ";
   for(ll i=2;i<=c2;i++) cout<<2<<" ";
   for(ll i=2;i<=c1;i++) cout<<1<<" ";
}


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

bool prime(int n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0,sum=1;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<1<<" ";
   c1--;
   for(ll i=1;i<n;i++){
         if(prime(sum+1)&&c1>0){
             cout<<1<<" ";
             c1--;
         }
         else if(prime(sum+2)&&c2>0){
             cout<<2<<" ";
             c2--;
         }
         else{
             if(c1>=c2&&c1>0){ cout<<1<<" "; c1--;}
             else if(c2>0) {cout<<2<<" "; c2--;}
             else {cout<<1<<" "; c1--;}
         }
   }
}


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

bool prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        return false;
    }
    return true;
}

int main()
{
   ll n,t,c1=0,c2=0,sum=2;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>t;
       if(t==1) c1++;
       else c2++;
   }
   if(c1==0){
       for(ll i=0;i<n;i++)
       cout<<2<<" ";
       return 0;
   }
   if(c2==0){
       for(ll i=0;i<n;i++)
       cout<<1<<" ";
       return 0;
   }
   cout<<2<<" ";
   c2--;
   for(ll i=1;i<n;i++){
         if(prime(sum+2)&&c2>0){
             cout<<2<<" ";
             c2--;
         }
         else if(prime(sum+1)&&c1>0){
             cout<<1<<" ";
             c1--;
         }
         else{
             if(c1>c2){ cout<<1<<" "; c1--;}
             else {cout<<2<<" "; c2--;}
         }
   }
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    b=0;
    a=0;
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(sum>=2&&vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else if(sum>=1&&vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    printf("%d",ans[1]);
    for(int i=2;i<=n;i++)
    {
        printf(" %d",ans[i]);
    }
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else if(vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=1;
                b--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",ans[i]);
    }
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    scanf("%d",&n);
    a=0;
    b=0;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(sum-1>=0&&vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
        }
        else if(sum-2>=0&&vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    printf("%d",ans[1]);
    for(int i=2;i<=n;i++)
    {
        printf(" %d",ans[i]);
    }
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else if(vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=1;
                b--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",ans[i]);
    }
    printf("\n");
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    b=0;
    a=0;
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(sum>=2&&vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else if(sum>=1&&vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=1;
                b--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    printf("%d",ans[1]);
    for(int i=2;i<=n;i++)
    {
        printf(" %d",ans[i]);
    }
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    scanf("%d",&n);
    a=0;
    b=0;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(sum-1>=0&&vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=1;
                b--;
                continue;
            }
        }
        else if(sum-2>=0&&vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    printf("%d",ans[1]);
    for(int i=2;i<=n;i++)
    {
        printf(" %d",ans[i]);
    }
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int n;
int a=0,b=0;
int vis[400005];
int ans[200005];
int main()
{
    vis[1]=1;
    for(int i=2;i<=400005;i++)
    {
        if(vis[i]==0)
        {
            for(int j=i+i;j<=400005;j=j+i)
            {
                vis[j]=1;
            }
        }
    }
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp==1) a++;
        else b++;
        sum+=tmp;
    }
    for(int i=n;i>=1;i--)
    {
        if(vis[sum-2]==0)
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
                continue;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
        }
        else if(vis[sum-1]==0)
        {
            if(a>0)
            {
                sum-=1;
                ans[i]=1;
                a--;
                continue;
            }
            else
            {
                sum-=2;
                ans[i]=1;
                b--;
                continue;
            }
        }
        else
        {
            if(b>0)
            {
                sum-=2;
                ans[i]=2;
                b--;
            }
            else
            {
                sum-=1;
                ans[i]=1;
                a--;
            }
        }
    }
    printf("%d",ans[0]);
    for(int i=2;i<=n;i++)
    {
        printf(" %d",ans[i]);
    }
}


#include <bits/stdc++.h>

using namespace std;
bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int main()
{
    int a[200000]={0};
    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    for(int i=2;i<sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<"2 ";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<"1 ";
                x++;
            }
            s=i-x;
        }
    }
    for(int i=0;i<sum1;i++)
        cout<<"1 ";
    for(int i=0;i<sum2;i++)
        cout<<"2 ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
/*bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int a[400000]={0};
int main()
{
    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    for(int i=2;i<sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<"2 ";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<"1 ";
                x++;
            }
            s=i-x;
        }
    }
    for(int i=0;i<sum1;i++)
        cout<<"1 ";
    for(int i=0;i<sum2;i++)
        cout<<"2 ";
    return 0;
}*/
int main()
{
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    if(sum2)
        cout<<"2 ",sum2--;
    if(sum1)
        cout<<"1 ",sum1--;
    while(sum2)
        cout<<"2 ",sum2--;
    while(sum1)
        cout<<"1 ",sum1--;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int main()
{
    int a[200000]={0};
    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    for(int i=2;i<=sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<"2 ";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<"1 ";
                x++;
            }
            s=i-x;
        }
    }
    for(int i=0;i<sum1;i++)
        cout<<"1 ";
    for(int i=0;i<sum2;i++)
        cout<<"2 ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int main()
{
    int a[200000]={0};
    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    for(int i=2;i<=sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<"2 ";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<"1 ";
                x++;
            }
            s=i-x;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int main()
{
    int a[200000]={0};
    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    if(sum1!=0)
    {
        cout<<"1";
        sum1--;
        x++;
    }
    for(int i=2;i<=sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<" 2";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<" 1";
                x++;
            }
            s=i-x;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
/*bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int a[400000]={0};
int main()
{
    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    for(int i=2;i<sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<"2 ";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<"1 ";
                x++;
            }
            s=i-x;
        }
    }
    for(int i=0;i<sum1;i++)
        cout<<"1 ";
    for(int i=0;i<sum2;i++)
        cout<<"2 ";
    return 0;
}*/
int main()
{
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    if(sum2)
        cout<<"2 ",sum2--;
    if(sum1)
        cout<<"1 ",sum1--;
    while(sum2)
        cout<<"2 ",sum2--;
    while(sum1)
        cout<<"1 ",sum1--;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool findd(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int a[400000]={0};
int main()
{

    for(int i=2;i<200000;i++)
        if(findd(i))
            a[i]=1;
    int n;
    cin>>n;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
            sum1++;
        else
            sum2++;
    }
    int sum=sum1+sum2*2;
    int x=0;
    for(int i=2;i<sum;i++)
    {
        if(a[i])
        {
            int s=i-x;
            for(int i=0;i<s/2&&sum2;i++)
            {
                sum2--;
                cout<<"2 ";
                x+=2;
            }
            s=i-x;
            for(int i=0;i<s&&sum1;i++)
            {
                sum1--;
                cout<<"1 ";
                x++;
            }
            s=i-x;
        }
    }
    for(int i=0;i<sum1;i++)
        cout<<"1 ";
    for(int i=0;i<sum2;i++)
        cout<<"2 ";
    return 0;
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
ll a;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0; i < n;i ++ ){
        cout<<2<<" ";
    }
    return 0;
}
for( int i=0; i < n;i++ ){
    if( cnt==0 or ans>0 and a%2==0 ){
        cout<<2<<" ",ans--;
    }
    else if( ans==0 or cnt>0 and a%2==1 ){
        cout<<1<<" ",cnt--;
    }
    a++;
}
if( ans!=0 )
    cout<<2;
if( cnt!=0 )
    cout<<1;
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0;i < n;i++ )
        cout<<2<<" ";
    return 0;
}
if( cnt==2 ){
    cout<<1<<" ";
for( int i=0;i < ans;i ++ ){
    cout<<2<<" ";
}
for( int i=0;i < cnt-1;i ++ )
    cout<<1<<" ";
    return 0;
}
if( cnt>2 or cnt==1){
        if( cnt%2==1 ){
for( int i=0;i < cnt;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
        }
        else{
           for( int i=0;i < cnt-1;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
    cout<<1;
        }
}
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
ll a;
int main(){
    ios_base::sync_with_stdio(NULL);
    cin >> n;
    for( int i = 2; i < N; i ++ )
    {
        if( a[i] == 0 )
        {
            v.pb( i );
            for( int j = i+i; j < N; j += i )
                a[j] = 1;
        }
    }
    for (int i = 0 ; i < n ; i ++ )
    {
        cin >> b ;
        if (b == 1)
            cnt ++ ;
        else if (b == 2)
            ans ++ ;
    }
    for (int i = 0 ; i < v.size() ; i ++ )
    {
        while (v[i] - e >= 2 and ans != 0)
        {
            ans -- ;
            cout << 2 << " " ;
            e += 2 ;
        }
        while (v[i] - e >= 1 and cnt != 0)
        {
            cnt -- ;
            cout << 1 << " ";
            e += 1 ;
        }
    }
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0; i < n;i ++ ){
        cout<<2<<" ";
    }
    return 0;
}
if( cnt==2 ){
    cout<<1<<" ";
    for( int i=0;i < ans;i ++ )
        cout<<2<<" ";
    cout<<1;
    return 0;
}

if( cnt==1 ){
        cout<<1<<" ";
    for( int i=0; i < n-1;i ++ )
    cout<<2<<" ";
return 0;
}
else{
    for( int i=0;i < 3;i ++ )
        cout<<1<<" ";
    for( int i=0; i < ans;i ++ )
        cout<<2<<" ";
    for( int i=0;i < cnt-3;i ++ )
        cout<<1<<" ";
    return 0;
}

}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
ll a;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0; i < n;i ++ ){
        cout<<2<<" ";
    }
    return 0;
}
for( int i=0; i < n;i++ ){
    if( cnt==0 and ans>0 and a%2==0 ){
        cout<<2<<" ",ans--;
    }
    else if( ans==0 or cnt>0 and a%2==1 ){
        cout<<1<<" ",cnt--;
    }
    a++;
}
if( ans!=0 )
    cout<<2;
if( cnt!=0 )
    cout<<1;
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
ll a;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0; i < n;i ++ ){
        cout<<2<<" ";
    }
    return 0;
}
if( ans!=0 ){
cout<<2<<" "<<1<<" ";
ans--;
cnt--;
}
    while(ans!=0)
        cout<<2<<" ",ans--;
    while(cnt!=0)
        cout<<1<<" ",cnt--;
        return 0;
for( int i=0; i < n;i ++ )
    cout<<1<<" ";
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( cnt==2 ){
    cout<<1<<" ";
for( int i=0;i < ans;i ++ ){
    cout<<2<<" ";
}
for( int i=0;i < cnt-1;i ++ )
    cout<<1<<" ";
    return 0;
}
if( cnt>2 or cnt==1){
        if( cnt%2==1 ){
for( int i=0;i < cnt;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
        }
        else{
           for( int i=0;i < cnt-1;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
    cout<<1;
        }
}
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front

using namespace std ;

const ll N = 1e6 + 1;

map <ll , ll> mp , pm ;
deque <ll> v , vc , ve ;
deque <ll> p , pe ;
deque <string> st ;
ll b , c , d , e , f , cnt , ans , r , n ;
float q , t , cnt1;
string g , h , w , o , z , m ;
char y , u ;
vector<pair < ll , ll > > pr;
char a[N];
int main ()
{
    bzbz
    mlojins
    CODER
    cin >> n;
    for( int i = 2; i < N; i ++ )
    {
        if( a[i] == 0 )
        {
            v.pb( i );
            for( int j = i+i; j < N; j += i )
                a[j] = 1;
        }
    }
    for (int i = 0 ; i < n ; i ++ )
    {
        cin >> b ;
        if (b == 1)
            cnt ++ ;
        else if (b == 2)
            ans ++ ;
    }
    for (int i = 0 ; i < v.size() ; i ++ )
    {
        while (v[i] - e >= 2 and ans != 0)
        {
            ans -- ;
            cout << 2 << " " ;
            e += 2 ;
        }
        while (v[i] - e >= 1 and cnt != 0)
        {
            cnt -- ;
            cout << 1 << " ";
            e += 1 ;
        }
    }
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0;i < n;i++ )
        cout<<2<<" ";
    return 0;
}
if( cnt==2 ){
    cout<<1<<" ";
for( int i=0;i < ans;i ++ ){
    cout<<2<<" ";
}
for( int i=0;i < cnt-1;i ++ )
    cout<<1<<" ";
    return 0;
}
if( cnt>2 or cnt==1){
        if( cnt%2==1 ){
for( int i=0;i < cnt;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
        }
        else{
           for( int i=0;i < 3;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
    for( int i=0;i < cnt-3;i ++ )
        cout<<1<<" ";
        }
}
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( cnt<=2 ){
    cout<<1<<" ";
for( int i=0;i < ans;i ++ ){
    cout<<2<<" ";
}
for( int i=0;i < cnt-1;i ++ )
    cout<<1<<" ";
    return 0;
}
if( cnt>2 ){
        if( cnt%2==1 ){
for( int i=0;i < cnt;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
        }
        else{
           for( int i=0;i < cnt-1;i ++ ){
    cout<<1<<" ";
}
for( int i=0;i < ans;i ++ )
    cout<<2<<" ";
    cout<<1;
        }
}
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define ld long double
#define pb push_back
using namespace std;

const long long N = 2e6;
ll n;
ll cnt;
ll ans;
int main(){
    ios_base::sync_with_stdio(NULL);
cin >> n;
ll arr[n];
for( int i=0;i < n;i ++ ){
    cin >> arr[i];
    if( arr[i]==1 )
        cnt++;
        else
            ans++;
}
if( ans==n ){
    for( int i=0; i < n;i ++ ){
        cout<<2<<" ";
    }
    return 0;
}
for( int i=0; i < n;i++ ){
    if( ans>0 and i%2==0 )
        cout<<2<<" ",ans--;
    else if( cnt>0 and i%2==1 )
        cout<<1<<" ",cnt--;
}
if( ans!=0 )
    cout<<2;
if( cnt!=0 )
    cout<<1;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s=0,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
      /*    if(y!=0)
          {
          if(y&1)
          s=y;
          else
          s=y-1;
          }
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1;*/
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(y>0)
          y-=1;
          for(i=0;i<y;i++)
          cout<<1<<" ";
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s=0,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
          if(y!=0)
          {
          if(y&1)
          s=y;
          else
          s=y-1;
          }
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1;
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
          if(y&1)
          s=y;
          else
          s=y-1;
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1;
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s=0,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
          if(y==1 && z>0)
          {
              cout<<2<<" "<<1;
              z-=1;
              for(i=0;i<z;i++)
              cout<<2<<" ";
              return ;
          }
          if(y!=0)
          {
          if(y&1)
          s=y;
          else
          s=y-1;
          }
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1;
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s=0,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
          if(y>=1 && z>0)
          {
              cout<<2<<" "<<1<<" ";
              z-=1;
              for(i=0;i<z;i++)
              cout<<2<<" ";
              y-=1;
              for(i=0;i<y;i++)
              cout<<1<<" ";
              return ;
          }
          if(y!=0)
          {
          if(y&1)
          s=y;
          else
          s=y-1;
          }
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1<<" ";
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s=0,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
          if(y==1 && z>0)
          {
              cout<<2<<" "<<1<<" ";
              z-=1;
              for(i=0;i<z;i++)
              cout<<2<<" ";
              return ;
          }
          if(y!=0)
          {
          if(y&1)
          s=y;
          else
          s=y-1;
          }
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1<<" ";
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

 void solution()
 {
          ll i,z=0,c,d,y=0,x,l=0,a,b,s=0,j,m,n,num,p,q,k,r;
         //vector<ll>v(n);
          cin>>n;
          for(i=0;i<n;i++)
          {
              cin>>k;
              if(k==1)
              y++;
              else
              z++;
          }
          if(y==1)
          {
              cout<<2<<" "<<1;
              z-=1;
              for(i=0;i<z;i++)
              cout<<2<<" ";
              return ;
          }
          if(y!=0)
          {
          if(y&1)
          s=y;
          else
          s=y-1;
          }
          for(i=0;i<s;i++)
          cout<<1<<" ";
          for(i=0;i<z;i++)
          cout<<2<<" ";
          if(s!=y)
          cout<<1;
 }

int main()
{  ios_base::sync_with_stdio(false);    cin.tie(NULL);
    ll tt;
tt=1;
//cin>>tt;
while(tt--)
{
solution();

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


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one%2==0 && one+two>1){
		FOR(i,0,one-1) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
		cout<<"1 ";
	}else{
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}
  	return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one==1 && two==1){
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}else{
		cout<<"2 1 ";
		FOR(i,0,two-1) cout<<"2 ";
		FOR(i,0,one-1) cout<<"1 ";

	}
  	return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one%2==0){
		FOR(i,0,one-1) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
		cout<<"1 ";
	}else{
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}
  	return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one==0 || two==0){
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}else{
		cout<<"2 1 ";
		FOR(i,0,two-1) cout<<"2 ";
		FOR(i,0,one-1) cout<<"1 ";

	}
  	return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one==1 && two==1){
		cout<<"2 1 ";
	}else if(one%2==0 && one+two>1){
		FOR(i,0,one-1) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
		cout<<"1 ";
	}else{
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}
  	return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one==1 && two==1){
		cout<<"2 1 ";
	}else if(one%2==0 && one+two>1 && one!=0){
		FOR(i,0,one-1) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
		cout<<"1 ";
	}else{
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}
  	return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n,one=0,two=0;

int main()
{
	cin>>n;
	int temp;
	FOR(i,0,n) {
		cin>>temp;
		temp==1 ? one++ : two++ ;
	}
	if(one==1 || two==1){
		FOR(i,0,one) cout<<"1 ";
		FOR(i,0,two) cout<<"2 ";
	}else{
		cout<<"2 1 ";
		FOR(i,0,two-1) cout<<"2 ";
		FOR(i,0,one-1) cout<<"1 ";

	}
  	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

vector<int> p(500);
int c=0;
int sum=0;
for ( int q=1;q<3000;q++)
{ bool prime=1;
     for (int i=2;i<=sqrt(q);i++)
 { if (q%i==0)
     { prime=false;
          break;
     }
 }
if(prime)
{p[c]=q;
c++;}
}
int n;
int x[3]={0};
cin >> n;
for (int q=0;q<n;q++)
{ int m;
cin >> m;
x[m]++;
}
int v=0;
int pre=0;

while (x[1] || x[2])
{ if(pre+2 <=p[v] && x[2])
    { pre+=2;
    cout << 2 << " ";
    x[2]--;
    }
    else
        if(pre+1<=p[v]&&x[1])
    { pre++;
        cout << 1 << " ";
        x[1]--;
    }
    if(pre==p[v])
        v++;
}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

vector<int> p(500);
int c=0;
int sum=0;
for ( int q=1;q<3000;q++)
{ bool prime=1;
     for (int i=2;i<=sqrt(q);i++)
 { if (q%i==0)
     { prime=false;
          break;
     }
 }
if(prime)
{p[c]=q;
c++;}
}
int n;
int x[3]={0};
cin >> n;
for (int q=0;q<n;q++)
{ int m;
cin >> m;
x[m]++;
}
int v=0;
int pre=0;
while (x[1] || x[2])
{ if(pre+2 <=p[v] && x[2])
    { pre+=2;
    cout << 2 << " ";
    x[2]--;
    }
    else if(pre+1<=p[v]&&x[1])
    { pre++;
        cout << 1 << " ";
        x[1]--;
    }
    else if (x[2])
    { cout << 2 << " ";
    pre+=2;
        x[2]--;
    }
    if(pre>=p[v])
        {v++;
       }
}

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2; i*i<MX; i++)
    {
        if(marked[i]==false)
        {
            for(ll j=i*i; j<MX; j+=i)
            {
                marked[j]=true;
            }
        }
    }

    for(ll i=2; i<MX; i++)
        if(!marked[i])
        {
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
    vpl factors;
    ll pf_id=0,pf=primes[pf_id];
    while(pf*pf<=N)
    {
        ll cnt=0;
        while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

        pf=primes[++pf_id];
    }

    if(N!=1) factors.push_back({N,1});
    return factors;
}

/**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0; i<n; i++)
    {
        ll a;
        cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;
    ll tempx=x,tempy=y;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y)
        {
            for(ll i=0; i<a/2; i++)
                res1.push_back(2),cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0; i<min(a,x); i++)
            res1.push_back(1),cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }

    x=tempx,y=tempy;
    if(x)
    {
        x--,cur=1;
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=2)
    {
        x-=2,cur=2;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=3)
    {
        x-=3,cur=3;
        cnt2=2;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    for(auto p:res1) cout<< p << " ";
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2;i*i<MX;i++){
        if(marked[i]==false){
            for(ll j=i*i;j<MX;j+=i){
                marked[j]=true;
            }
        }
    }

    for(ll i=2;i<MX;i++)
        if(!marked[i]){
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
	vpl factors;
	ll pf_id=0,pf=primes[pf_id];
	while(pf*pf<=N){
        ll cnt=0;
		while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

		pf=primes[++pf_id];
	}

	if(N!=1) factors.push_back({N,1});
    return factors;
}

                        /**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0;i<n;i++){
        ll a; cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y){
            for(ll i=0;i<a/2;i++)
                cout<< 2 << " ",cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0;i<min(a,x);i++)
            cout<< 1 << " ",cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2;i*i<MX;i++){
        if(marked[i]==false){
            for(ll j=i*i;j<MX;j+=i){
                marked[j]=true;
            }
        }
    }

    for(ll i=2;i<MX;i++)
        if(!marked[i]){
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
	vpl factors;
	ll pf_id=0,pf=primes[pf_id];
	while(pf*pf<=N){
        ll cnt=0;
		while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

		pf=primes[++pf_id];
	}

	if(N!=1) factors.push_back({N,1});
    return factors;
}

                        /**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0;i<n;i++){
        ll a; cin>> a;
        if(a==1) x++;
        else y++;
    }

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y){
            for(ll i=0;i<a/2;i++)
                cout<< 2 << " ";
            y-=a/2;
            a-=a/2;
        }
        for(ll i=0;i<min(a,x);i++)
            cout<< 1 << " ",x--;
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2; i*i<MX; i++)
    {
        if(marked[i]==false)
        {
            for(ll j=i*i; j<MX; j+=i)
            {
                marked[j]=true;
            }
        }
    }

    for(ll i=2; i<MX; i++)
        if(!marked[i])
        {
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
    vpl factors;
    ll pf_id=0,pf=primes[pf_id];
    while(pf*pf<=N)
    {
        ll cnt=0;
        while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

        pf=primes[++pf_id];
    }

    if(N!=1) factors.push_back({N,1});
    return factors;
}

/**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0; i<n; i++)
    {
        ll a;
        cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;
    ll tempx=x,tempy=y;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y)
        {
            for(ll i=0; i<a/2; i++)
                res1.push_back(2),cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0; i<min(a,x); i++)
            res1.push_back(1),cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }

    x=tempx,y=tempy;
    if(x)
    {
        x--,cur=1;
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2;
    for(auto p:res1) cout<< p << " ";
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2; i*i<MX; i++)
    {
        if(marked[i]==false)
        {
            for(ll j=i*i; j<MX; j+=i)
            {
                marked[j]=true;
            }
        }
    }

    for(ll i=2; i<MX; i++)
        if(!marked[i])
        {
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
    vpl factors;
    ll pf_id=0,pf=primes[pf_id];
    while(pf*pf<=N)
    {
        ll cnt=0;
        while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

        pf=primes[++pf_id];
    }

    if(N!=1) factors.push_back({N,1});
    return factors;
}

/**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0; i<n; i++)
    {
        ll a;
        cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;
    ll tempx=x,tempy=y;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y)
        {
            for(ll i=0; i<a/2; i++)
                res1.push_back(2),cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0; i<min(a,x); i++)
            res1.push_back(1),cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }

    x=tempx,y=tempy;
    if(x)
    {
        x--,cur=1;
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=2)
    {
        x-=2,cur=2;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=3)
    {
        x-=3,cur=3;
        cnt2=2;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x and y)
    {
        x-=3,cur=3;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(2);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    for(auto p:res1) cout<< p << " ";
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 105
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2;i*i<MX;i++){
        if(marked[i]==false){
            for(ll j=i*i;j<MX;j+=i){
                marked[j]=true;
            }
        }
    }

    for(ll i=2;i<MX;i++)
        if(!marked[i]){
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
	vpl factors;
	ll pf_id=0,pf=primes[pf_id];
	while(pf*pf<=N){
        ll cnt=0;
		while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

		pf=primes[++pf_id];
	}

	if(N!=1) factors.push_back({N,1});
    return factors;
}

                        /**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    ll n;
    cin>> n;
    ll grid[55][55];
    memset(grid,false,sizeof grid);
    string str[55];

    for(ll i=0;i<n;i++){
        string s;
        cin>> s;
        str[i]=s;
        for(ll j=0;j<n;j++)
            if(s[j]=='#')
                grid[i][j]=1;
    }

    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++){
            if(str[i][j]=='.' && i+1<n && str[i+1][j]=='.' && i-1>=0 && str[i-1][j]=='.'){
                if(j+1<n and str[i][j+1]=='.' and j-1>=0 and str[i][j-1]=='.'){
                    if(!grid[i][j] and !grid[i+1][j] and !grid[i-1][j] and !grid[i][j+1] and !grid[i][j-1])
                        {grid[i][j]++;grid[i+1][j]++;grid[i-1][j]++;grid[i][j+1]++;grid[i][j-1]++;}
                }
            }
        }

    string s="YES";
    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            if(grid[i][j]!=1)
                s="NO";

    cout<< s;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2; i*i<MX; i++)
    {
        if(marked[i]==false)
        {
            for(ll j=i*i; j<MX; j+=i)
            {
                marked[j]=true;
            }
        }
    }

    for(ll i=2; i<MX; i++)
        if(!marked[i])
        {
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
    vpl factors;
    ll pf_id=0,pf=primes[pf_id];
    while(pf*pf<=N)
    {
        ll cnt=0;
        while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

        pf=primes[++pf_id];
    }

    if(N!=1) factors.push_back({N,1});
    return factors;
}

/**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0; i<n; i++)
    {
        ll a;
        cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;
    ll tempx=x,tempy=y;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y)
        {
            for(ll i=0; i<a/2; i++)
                res1.push_back(2),cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0; i<min(a,x); i++)
            res1.push_back(1),cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }

    x=tempx,y=tempy;
    if(x)
    {
        x--,cur=1;
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=2)
    {
        x-=2,cur=2;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=3)
    {
        x-=3,cur=3;
        cnt2=2;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x and y)
    {
        x-=1,y--,cur=3;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(2);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    for(auto p:res1) cout<< p << " ";
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2;i*i<MX;i++){
        if(marked[i]==false){
            for(ll j=i*i;j<MX;j+=i){
                marked[j]=true;
            }
        }
    }

    for(ll i=2;i<MX;i++)
        if(!marked[i]){
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
	vpl factors;
	ll pf_id=0,pf=primes[pf_id];
	while(pf*pf<=N){
        ll cnt=0;
		while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

		pf=primes[++pf_id];
	}

	if(N!=1) factors.push_back({N,1});
    return factors;
}

                        /**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0;i<n;i++){
        ll a; cin>> a;
        if(a==1) x++;
        else y++;
    }

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y){
            for(ll i=0;i<a/2;i++)
                cout<< 2 << " ",cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0;i<min(a,x);i++)
            cout<< 1 << " ",x--,cur++;
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2; i*i<MX; i++)
    {
        if(marked[i]==false)
        {
            for(ll j=i*i; j<MX; j+=i)
            {
                marked[j]=true;
            }
        }
    }

    for(ll i=2; i<MX; i++)
        if(!marked[i])
        {
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
    vpl factors;
    ll pf_id=0,pf=primes[pf_id];
    while(pf*pf<=N)
    {
        ll cnt=0;
        while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

        pf=primes[++pf_id];
    }

    if(N!=1) factors.push_back({N,1});
    return factors;
}

/**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0; i<n; i++)
    {
        ll a;
        cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;
    ll tempx=x,tempy=y;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y)
        {
            for(ll i=0; i<a/2; i++)
                res1.push_back(2),cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0; i<min(a,x); i++)
            res1.push_back(1),cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }

    x=tempx,y=tempy;
    if(x)
    {
        x--,cur=1;
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=2)
    {
        x-=2,cur=2;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=3)
    {
        x-=3,cur=3;
        cnt2=2;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x and y)
    {
        x-=1,y--,cur=3;
        cnt2=2;
        res2.clear();
        res2.push_back(1);
        res2.push_back(2);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<cnt2)
        res1=res2,cnt1=cnt2;

    if(cnt1<cnt2)
        res1=res2,cnt1=cnt2;

    for(auto p:res1) cout<< p << " ";
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2;i*i<MX;i++){
        if(marked[i]==false){
            for(ll j=i*i;j<MX;j+=i){
                marked[j]=true;
            }
        }
    }

    for(ll i=2;i<MX;i++)
        if(!marked[i]){
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
	vpl factors;
	ll pf_id=0,pf=primes[pf_id];
	while(pf*pf<=N){
        ll cnt=0;
		while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

		pf=primes[++pf_id];
	}

	if(N!=1) factors.push_back({N,1});
    return factors;
}

                        /**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0;i<n;i++){
        ll a; cin>> a;
        if(a==1) x++;
        else y++;
    }

    ll cur=0;
    if(y)
        cout<< 2 << " ",y--;
    if(x)
        cout<< 1 << " ",x--;
    while(y)
        cout<< 2 << " ",y--;
    while(x)
        cout<< 1 << " ",x--;
}