#include <bits/stdc++.h>
using namespace std;
long long int prime[400001];
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  prime[0] |= (1 << 0);
  prime[1] |= (1 << 1);
  for (long long int i = 4; i <= 400000; i += 2)
    prime[i >> 5] |= (1 << (i & 31));
  for (long long int i = 3; i * i <= 400000; i += 2)
    if (!(prime[i >> 5] & (1 << (i & 31))))
      for (long long int j = i * i; j <= 400000; j += 2 * i)
        prime[j >> 5] |= (1 << (j & 31));
  long long int n;
  cin >> n;
  long long int ar[n];
  ar[0] = 1;
  long long int x, i, one = 0, two = 0;
  for (i = 0; i < n; ++i) {
    cin >> x;
    ar[0] = max(ar[0], x);
    if (x == 1)
      ++one;
    else
      ++two;
  }
  long long int sum = ar[0];
  if (ar[0] == 1)
    --one;
  else
    --two;
  for (i = 1; i < n; ++i) {
    if (!(prime[(sum + 1) >> 5] & (1 << ((sum + 1) & 31))) and one) {
      ++sum;
      --one;
      ar[i] = 1;
    } else if (!(prime[(sum + 2) >> 5] & (1 << ((sum + 2) & 31))) and two) {
      sum += 2;
      --two;
      ar[i] = 2;
    } else {
      if (one >= two) {
        ++sum;
        --one;
        ar[i] = 1;
      } else {
        sum += 2;
        --two;
        ar[i] = 2;
      }
    }
  }
  for (i = 0; i < n; ++i) cout << ar[i] << " ";
  cout << "\n";
  return 0;
}
