#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n;
while(cin>>n)
{
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
{
if(a[i]==1)
cout<<a[i]<<" ";
}
for(int i=0;i<n;i++)
{
if(a[i]==2)
cout<<a[i]<<" ";
}
for(int i=0;i<n;i++)
{
if(a[i]==3)
cout<<a[i]<<" ";
}
}
return 0;
}