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