#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  int n, m, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b6 = 0, t = 0, b5 = 0, b7 = 0;
  cin >> n;
  m = n / 3;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    if (a[i] == 1)
      b1++;
    else if (a[i] == 2)
      b2++;
    else if (a[i] == 3)
      b3++;
    else if (a[i] == 4)
      b4++;
    else if (a[i] == 6)
      b6++;
    else if (a[i] == 5)
      b5++;
    else if (a[i] == 7)
      b7++;
  }
  if ((b1 == m) && (b6 + b4 == b1) && (b4 <= b2) && (b3 <= b6) && (b5 == 0) &&
      (b7 == 0)) {
    for (int i = 0; i < b3; i++) {
      cout << "1 3 6" << endl;
      t++;
    }
    for (int i = 0; i < b4; i++) {
      cout << "1 2 4" << endl;
      t++;
    }
    for (int i = 0; i < m - t; i++) cout << "1 2 6" << endl;
  } else
    cout << "-1";
}
