#include <bits/stdc++.h>
using namespace std;
int a[(int)(1e+6) * 2], b[10], c[10];
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    b[a[i]]++;
    if (b[5] > 0 || b[7] > 0) {
      cout << -1;
      return 0;
    }
  }
  b[2] -= b[4];
  b[1] -= b[4];
  if (b[2] < 0 || b[1] < 0) {
    cout << -1;
    return 0;
  }
  if (!(b[1] == b[6] && b[6] == b[2] + b[3])) {
    cout << -1;
    return 0;
  }
  for (i = 1; i <= b[4]; i++) cout << "1 2 4\n";
  for (i = 1; i <= b[2]; i++) cout << "1 2 6\n";
  for (i = 1; i <= b[3]; i++) cout << "1 3 6\n";
}
