#include <bits/stdc++.h>
using namespace std;
int ar[100000 + 9], a[100000 + 9];
int main() {
  long long n, m, ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> m;
    ar[m]++;
  }
  if (ar[1] == 0 || ar[2] == 0 || ar[4] == 0) {
    if (ar[1] == 0 || ar[2] == 0 || ar[6] == 0) {
      if (ar[1] == 0 || ar[3] == 0 || ar[6] == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  while (ar[1] > 0 && ar[2] > 0 && ar[4] > 0) {
    ans += 3;
    ar[1]--;
    ar[2]--;
    ar[4]--;
    a[1]++;
    a[2]++;
    a[4]++;
  }
  while (ar[1] > 0 && ar[2] > 0 && ar[6] > 0) {
    ans += 3;
    ar[1]--;
    ar[2]--;
    ar[6]--;
    a[1]++;
    a[2]++;
    a[6]++;
  }
  while (ar[1] > 0 && ar[3] > 0 && ar[6] > 0) {
    ans += 3;
    ar[1]--;
    ar[3]--;
    ar[6]--;
    a[1]++;
    a[3]++;
    a[6]++;
  }
  if (ans == n) {
    while (a[1] > 0 && a[2] > 0 && a[4] > 0) {
      cout << 1 << " " << 2 << " " << 4 << endl;
      a[1]--;
      a[2]--;
      a[4]--;
    }
    while (a[1] > 0 && a[2] > 0 && a[6] > 0) {
      cout << 1 << " " << 2 << " " << 6 << endl;
      a[1]--;
      a[2]--;
      a[6]--;
    }
    while (a[1] > 0 && a[3] > 0 && a[6] > 0) {
      cout << 1 << " " << 3 << " " << 6 << endl;
      a[1]--;
      a[3]--;
      a[6]--;
    }
  } else
    cout << -1 << endl;
  return 0;
}
