#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, count1 = 0, count2 = 0, count3 = 0, count4 = 0, count6 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 5 || x == 7) {
      cout << "-1" << endl;
      return 0;
    } else if (x == 1)
      count1++;
    else if (x == 2)
      count2++;
    else if (x == 3)
      count3++;
    else if (x == 4)
      count4++;
    else if (x == 6)
      count6++;
  }
  if (n / 3 == count1 && count6 >= count3 &&
      (count4 + (count6 - count3)) == count2) {
    for (int i = 0; i < count3; i++) cout << "1 3 6" << endl;
    for (int i = 0; i < count4; i++) cout << "1 2 4" << endl;
    for (int i = 0; i < count6 - count3; i++) cout << "1 2 6" << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
