#include <bits/stdc++.h>
namespace io {
template <typename T>
inline void read(T& a) {
  int c = getchar(), sign = 0;
  a = 0;
  while (c < '0' || c > '9') sign += (c == '-'), c = getchar();
  while (c >= '0' && c <= '9') a = (a << 1) + (a << 3) + c - 48, c = getchar();
  if (sign & 1) a = -a;
}
template <typename T>
inline void Write(T a) {
  if (a > 9) Write(a / 10);
  putchar(a % 10 + '0');
}
template <typename T>
inline void write(T a, char ch = ' ') {
  if (a < 0) putchar('-'), a = -a;
  Write(a);
  putchar(ch);
}
}  // namespace io
using namespace io;
using namespace std;
const int maxn = 2e5;
const int mod = 1e9 + 7;
int n, q, d, m, a[maxn + 3], b[maxn + 3];
int dem[maxn + 3], id[maxn + 3];
int k, h;
int res = 2e9;
long long dp[maxn + 5], t[maxn + 3];
string second;
bool kt[maxn + 3];
map<int, int> maps;
vector<int> edge[maxn + 3];
map<int, int>::iterator it;
template <typename T>
void answer(T x) {
  cout << x;
  exit(0);
}
void putstring(string x, char ch = ' ') {
  for (char c : x) putchar(c);
  putchar(ch);
}
int dx[5] = {0, 0, 0, 1, -1}, dy[5] = {0, 1, -1, 0, 0};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  cin >> n;
  int t = 0;
  int bd[3];
  bd[1] = bd[2] = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i], t += a[i], bd[a[i]]++;
  for (int i = 2; i * i <= t; ++i) {
    if (kt[i]) continue;
    for (int j = i * i; j <= t; j += i) kt[j] = true;
  }
  int now = 0;
  vector<int> chot;
  for (int i = 2; i <= t; ++i)
    if (!kt[i]) chot.push_back(i);
  chot.push_back(1e9);
  reverse(chot.begin(), chot.end());
  vector<int> ans;
  while (bd[1] || bd[2]) {
    int kq;
    if (chot.back() - now == 2 && bd[2])
      bd[2]--, kq = 2, chot.pop_back();
    else if (chot.back() - now == 1 && bd[1])
      bd[1]--, kq = 1, chot.pop_back();
    else if (bd[1] > bd[2])
      bd[1]--, kq = 1;
    else
      bd[2]--, kq = 2;
    now += kq;
    ans.push_back(kq);
  }
  for (auto& x : ans) write(x);
}
