#include <bits/stdc++.h>
using namespace std;
const int N = 10;
long long n, a[N], k, mn;
vector<long long> v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> k;
    a[k]++;
  }
  if (a[5] > 0 || a[7] > 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    mn = min(min(a[1], a[2]), a[4]);
    a[1] -= mn;
    a[2] -= mn;
    a[4] -= mn;
    if (mn != 0) {
      for (int j = 1; j <= mn; j++) {
        v.push_back(1);
        v.push_back(2);
        v.push_back(4);
      }
    }
    mn = min(min(a[1], a[2]), a[6]);
    a[1] -= mn;
    a[2] -= mn;
    a[6] -= mn;
    if (mn != 0) {
      for (int j = 1; j <= mn; j++) {
        v.push_back(1);
        v.push_back(2);
        v.push_back(6);
      }
    }
    mn = min(min(a[1], a[3]), a[6]);
    a[1] -= mn;
    a[3] -= mn;
    a[6] -= mn;
    if (mn != 0) {
      for (int j = 1; j <= mn; j++) {
        v.push_back(1);
        v.push_back(3);
        v.push_back(6);
      }
    }
  }
  if (a[1] > 0 || a[2] > 0 || a[4] > 0 || a[6] > 0)
    cout << "-1" << endl;
  else
    for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  return 0;
}
