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