#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
bool isprime(long long num) {
  for (long long i = 2; i * i <= num; ++i) {
    if (num % i == 0) return false;
  }
  return true;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return ((a / gcd(a, b)) * b); }
long long cel(long long x1, long long y1) {
  if ((x1) <= 0) return (x1) / (y1);
  return (((x1) / (y1)) + (((x1) % (y1)) != 0));
}
int power(int x, unsigned int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
bool cakewalk(long long int n) {
  if (n == 1) return true;
  if (n % 10 != 0) return false;
  if (n % 20 == 0) return cakewalk(n / 20) || cakewalk(n / 10);
  if (n % 10 == 0) return cakewalk(n / 10);
}
void solve(int test_case) {
  int n;
  cin >> n;
  int a[8] = {0};
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    a[b]++;
  }
  if (a[7] > 0 || a[5] > 0) {
    cout << -1;
    return;
  }
  if (a[1] != n / 3 || a[2] < a[4] || a[2] + a[3] < a[6] || a[1] < a[6]) {
    cout << -1;
    return;
  }
  int x, y, z;
  x = a[4];
  a[1] -= x;
  a[2] -= x;
  a[4] -= x;
  y = a[3];
  a[1] -= y;
  a[3] -= y;
  a[6] -= y;
  z = a[1];
  a[1] -= z;
  a[2] -= z;
  a[6] -= z;
  for (int i = 0; i < 8; i++) {
    if (a[i] != 0) {
      cout << -1;
      return;
    }
  }
  while (x--) cout << "1 2 4" << endl;
  while (y--) cout << "1 3 6" << endl;
  while (z--) cout << "1 2 6" << endl;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  while (tc--) {
    solve(tc);
  }
  return 0;
}
