#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, onecount = 0, twocount = 0, threecount = 0, fourcount = 0,
         sixcount = 0;
  int doobie;
  cin >> n;
  int counter[99999];
  vector<int> snap;
  for (int i = 0; i < 99999; ++i) {
    counter[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    cin >> doobie;
    counter[doobie]++;
  }
  if ((counter[1] == n / 3) &&
      (counter[6] == counter[3] + (counter[2] - counter[4])) &&
      (counter[5] == 0) && (counter[7] == 0) &&
      (counter[1] == (counter[2] + counter[3] + counter[4] + counter[6]) / 2)) {
    if ((counter[3] > 0) && (counter[6] == 0))
      cout << -1 << endl;
    else if (counter[3] > counter[6])
      cout << -1 << endl;
    else {
      while (counter[1] != 0) {
        if ((counter[6] > 0) && (counter[3] > 0)) {
          cout << 1 << " " << 3 << " " << 6 << endl;
          counter[3]--;
          counter[6]--;
          counter[1]--;
        } else if ((counter[6] > 0) && (counter[3] == 0)) {
          cout << 1 << " " << 2 << " " << 6 << endl;
          counter[6]--;
          counter[2]--;
          counter[1]--;
        } else if ((counter[6] == 0) && (counter[4] > 0)) {
          cout << 1 << " " << 2 << " " << 4 << endl;
          counter[2]--;
          counter[4]--;
          counter[1]--;
        }
      }
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
