#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int l = 0, u, n = 0, i = 0, d = 0, mx2 = -1, g, mul = 1, m = 0,
                e = 0, c = 0, x, y, j = 0, f = 0, k = 0, sum = 0, s = 0,
                mn = INT_MIN, mx = INT_MAX;
  cin >> n;
  map<int, int> a;
  for (i = 0; i < n; i++) {
    cin >> m;
    a[m]++;
  }
  if (a[5] != 0) {
    l = 1;
  } else if (a[7] != 0) {
    l = 1;
  } else {
    if (a[3] > 0 && a[3] <= a[6] && a[3] <= a[1]) {
      a[6] -= a[3];
      d = a[3];
      a[1] -= a[3];
    }
    if (a[1] > 0 && a[1] == (a[6] + a[4]) && a[1] == a[2] && l == 0) {
      j = a[1];
    }
  }
  if (d + j == (n / 3)) {
    while (d--) {
      cout << "1 3 6" << endl;
    }
    while (a[6]--) {
      cout << "1 2 6" << endl;
    }
    while (a[4]--) {
      cout << "1 2 4" << endl;
    }
  } else {
    l = 1;
  }
  if (l == 1) {
    cout << "-1";
  }
  return 0;
}
