#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  int o = 0, t = 0, th = 0, f = 0, s = 0;
  for (int i = 0; i < n; i++) {
    if (ar[i] == 1)
      o++;
    else if (ar[i] == 2)
      t++;
    else if (ar[i] == 3)
      th++;
    else if (ar[i] == 4)
      f++;
    else if (ar[i] == 6)
      s++;
  }
  if (o == (n / 3) && (th + t) == (n / 3) && (f + s) == (n / 3) && s >= th) {
    for (int i = 0; i < th; i++) {
      cout << "1 3 6\n";
      c++;
    }
    for (int i = 0; i < f; i++) {
      cout << "1 2 4\n";
      c++;
    }
    for (int i = (n / 3) - c; i > 0; i--) {
      cout << "1 2 6\n";
    }
  } else
    cout << -1;
}
