#include <bits/stdc++.h>
using namespace std;
int main() {
  int aa[10], bil, n;
  bool ada;
  cin >> n;
  for (int i = 1; i <= 7; i++) aa[i] = 0;
  ada = false;
  for (int i = 1; i <= n; i++) {
    cin >> bil;
    if (bil == 5 || bil == 7) ada = true;
    aa[bil]++;
  }
  int a, b, c;
  a = aa[4];
  c = aa[3];
  b = aa[1] - a - c;
  if (a >= 0 && b >= 0 && c >= 0 && a + b == aa[2] && b + c == aa[6] &&
      ada == false) {
    for (int i = 1; i <= a; i++) cout << "1 2 4\n";
    for (int i = 1; i <= b; i++) cout << "1 2 6\n";
    for (int i = 1; i <= c; i++) cout << "1 3 6\n";
  } else
    cout << "-1\n";
  return 0;
}
