#include <iostream>
#define REP(X) for(int i = 0;i < X;i++)
using namespace std;
int main(){
int ct[3] = {}, n;
cin >> n;
while(cin >> n)ct[n % 3]++;
REP(ct[1])cout << "1 ";
REP(ct[2])cout << "2 ";
REP(ct[0])cout << "3 ";
cout << endl;
return 0;
}
//由於僅有1~3,採用counting sort
//第一筆測資即為範例測資, 只要小心不要對應錯陣列就OK了