#include <bits/stdc++.h>
using namespace std;
void seive(bool a[], long long int n) {
  for (int i = 2; i * i <= n; i++) {
    if (a[i] == true) {
      for (int j = i * i; j <= n; j += i) a[j] = false;
    }
  }
}
int np(bool a[], long long int ppr, long long int n) {
  ppr++;
  while (ppr <= n) {
    if (a[ppr] == true) return ppr;
    ppr++;
  }
  return -1;
}
int main() {
  long long int n, i, n_1 = 0, n_2 = 0, sum = 0, s;
  int t;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t;
    if (t == 1)
      n_1++;
    else
      n_2++;
    sum += t;
  }
  bool a[sum + 1];
  memset(a, true, sizeof(a));
  seive(a, sum);
  s = 0;
  a[1] = false;
  long long int ppr = 0, pr;
  while (s <= sum && pr != -1) {
    pr = np(a, ppr, sum);
    if (pr - ppr >= 2 && pr != -1) {
      s = pr;
      int m = min(n_2, (pr - ppr) / 2);
      n_2 -= m;
      for (i = 0; i < m; i++) cout << 2 << " ";
      m = min(n_1, 2 * ((pr - ppr) / 2 - m));
      n_1 -= m;
      for (i = 0; i < m; i++) cout << 1 << " ";
      ppr = pr;
    } else if (pr != -1) {
      n_1--;
      if (n_1 < 0) {
        for (i = 0; i < n_1; i++) cout << 1 << " ";
        for (i = 0; i < n_2; i++) cout << 2 << " ";
        pr = -1;
      } else {
        cout << 1 << " ";
      }
      ppr = pr;
    } else {
      for (i = 0; i < n_1; i++) cout << 1 << " ";
      for (i = 0; i < n_2; i++) cout << 2 << " ";
    }
    if (n_1 <= 0 && n_2 <= 0) break;
  }
  return 0;
}
