#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, temp2, temp3, temp, a[10] = {0};
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> temp;
    a[temp]++;
  }
  if (a[0] > 0 || a[5] > 0 || a[7] > 0) {
    cout << -1;
    exit(0);
  }
  if (a[1] != n / 3) {
    cout << -1;
    return 0;
  }
  temp = a[3];
  a[6] = a[6] - a[3];
  a[3] = 0;
  if (a[6] < 0) {
    cout << -1;
    exit(0);
  }
  a[2] = a[2] - a[6];
  temp2 = a[6];
  a[6] = 0;
  if (a[2] < 0) {
    cout << -1;
    exit(0);
  }
  temp3 = a[2];
  if (a[2] != a[4]) {
    cout << -1;
    exit(0);
  }
  for (i = 0; i < temp3; i++) cout << 1 << " " << 2 << " " << 4 << endl;
  for (i = 0; i < temp2; i++) cout << 1 << " " << 2 << " " << 6 << endl;
  for (i = 0; i < temp; i++) cout << 1 << " " << 3 << " " << 6 << endl;
  return 0;
}
