#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long poww(long long a, int b) {
  long long ans = 1;
  for (int i = 1; i <= b; i++) ans *= a;
  return ans;
}
int prime[1000006];
void sieve() {
  prime[0] = prime[1] = -1;
  for (long long i = 2; i <= 1000004; i++) {
    if (prime[i] == 0) {
      for (long long j = i * 2; j <= 1000004; j += i) prime[j] = -1;
    }
  }
}
map<int, int> m;
vector<int> v;
int main() {
  int n, a1, a2, a3, a4, a6, ele;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ele;
    m[ele]++;
  }
  if (m[5] || m[7]) {
    cout << "-1";
    return 0;
  }
  a1 = m[1];
  a2 = m[2];
  a3 = m[3];
  a4 = m[4];
  a6 = m[6];
  while (a1 > 0 && a2 > 0 && a4 > 0) {
    v.push_back(1);
    v.push_back(2);
    v.push_back(4);
    a1--;
    a2--;
    a4--;
  }
  while (a1 > 0 && a3 > 0 && a6 > 0) {
    v.push_back(1);
    v.push_back(3);
    v.push_back(6);
    a1--;
    a3--;
    a6--;
  }
  while (a1 > 0 && a2 > 0 && a6 > 0) {
    v.push_back(1);
    v.push_back(2);
    v.push_back(6);
    a1--;
    a2--;
    a6--;
  }
  if (a1 != 0 || a2 != 0 || a3 != 0 || a4 != 0 || a6 != 0) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (i > 0 && (i % 3 == 0)) cout << endl;
    cout << v[i] << " ";
  }
  return 0;
}
