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