#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0, s6 = 0, s7 = 0;
  cin >> n;
  int p = n / 3;
  while (n--) {
    cin >> x;
    if (x == 1) {
      s1++;
    } else if (x == 2) {
      s2++;
    } else if (x == 3) {
      s3++;
    } else if (x == 4) {
      s4++;
    } else if (x == 5) {
      s5++;
    } else if (x == 6) {
      s6++;
    } else if (x == 7) {
      s7++;
    }
  }
  if (s7 > 0 || s5 > 0) {
    cout << "-1" << endl;
    return 0;
  }
  if (s1 != p) {
    cout << "-1" << endl;
    return 0;
  }
  if ((s2 + s3) != p) {
    cout << "-1" << endl;
    return 0;
  }
  if ((s4 + s6) != p) {
    cout << "-1" << endl;
    return 0;
  }
  if (s1 == 1 && s4 == 1 && s2 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  if (s1 == 1 && s6 == 1 && s4 == 1) {
    cout << "-1" << endl;
    return 0;
  }
  if (s3 > s6) {
    cout << "-1" << endl;
    return 0;
  }
  if (s4 > s2) {
    cout << "-1" << endl;
    return 0;
  }
  int count = 0, pount = 0;
  for (int i = 0; i < s3; i++) {
    cout << "1 3 6\n";
    count++;
  }
  for (int i = 0; i < s4; i++) {
    cout << "1 2 4\n";
    pount++;
  }
  for (int i = 0; i < (p - (count + pount)); i++) cout << "1 2 6\n";
  cout << endl;
}
