#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
int snt[500000], b[200010], tmp = 0;
int n, a[10], c;
void sangnt() {
  snt[0] = 1;
  snt[1] = 1;
  for (int i = 2; i <= 500000; i++)
    if (snt[i] == 0)
      for (int j = i; j <= 500000 / i; j++) snt[i * j] = 1;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    a[c]++;
  }
  int cur = 0, j = 0;
  sangnt();
  for (int i = 1; i <= 400000; i++)
    if (!snt[i]) b[tmp++] = i;
  while (a[2] && a[1]) {
    if (b[j] - cur >= 2 && a[2]) {
      cout << 2 << " ";
      a[2]--;
      cur += 2;
    } else if (a[1]) {
      cout << 1 << " ";
      a[1]--;
      cur++;
    }
    if (b[j] <= cur) j++;
  }
  while (a[1]--) {
    cout << 1 << " ";
  }
  while (a[2]--) cout << 2 << " ";
}
int main() { solve(); }
