#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *arr = new int[n];
  int one = 0;
  int two = 0;
  int three = 0;
  int four = 0;
  int six = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 1) one += 1;
    if (arr[i] == 2) two += 1;
    if (arr[i] == 4) four += 1;
    if (arr[i] == 6) six += 1;
    if (arr[i] == 3) three += 1;
  }
  int to_check = n / 3;
  if (one != to_check or two > to_check or three > to_check or
      four > to_check or six > to_check) {
    cout << -1;
    return 0;
  }
  vector<vector<int>> v(to_check, vector<int>(3, 0));
  for (int i = 0; i < to_check; i++) {
    v.at(i).at(0) = 1;
    one--;
  }
  int counter = 0;
  while (two > 0 and four > 0 and counter < to_check) {
    v.at(counter).at(1) = 2;
    two--;
    v.at(counter).at(2) = 4;
    four--;
    counter++;
  }
  while (two > 0 and six > 0 and counter < to_check) {
    v.at(counter).at(1) = 2;
    two--;
    v.at(counter).at(2) = 6;
    six--;
    counter++;
  }
  while (three > 0 and six > 0 and counter < to_check) {
    v.at(counter).at(1) = 3;
    two--;
    v.at(counter).at(2) = 6;
    six--;
    counter++;
  }
  if (counter < to_check) {
    cout << -1 << endl;
    return 0;
  }
  for (auto i : v) {
    for (auto j : i) {
      cout << j << " ";
    }
    cout << endl;
  }
  return 0;
}
