#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  for (int v = max(x, y); v >= 1; v--) {
    if (x % v == 0 && y % v == 0) return v;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int arr[9];
  for (int wt = 0; wt < 9; wt++) arr[wt] = 0;
  bool bad = false;
  int x, y;
  cin >> x;
  for (int v = 0; v < x; v++) {
    cin >> y;
    arr[y]++;
    if (y == 5 || y == 7) bad = true;
  }
  int four = 0, tsix = 0, ttsix = 0;
  if (arr[1] >= arr[4] && arr[2] >= arr[4]) {
    arr[2] -= arr[4];
    arr[1] -= arr[4];
    four = arr[4];
  } else
    bad = true;
  if (arr[1] >= arr[2] && arr[6] >= arr[2]) {
    arr[1] -= arr[2];
    arr[6] -= arr[2];
    tsix = arr[2];
  } else
    bad = true;
  if (arr[1] == arr[3] && arr[3] == arr[6]) {
    ttsix = arr[3];
  } else
    bad = true;
  if (bad)
    cout << "-1" << endl;
  else {
    int i = 0;
    for (i = 0; i < four; i++) cout << "1 2 4\n";
    for (i = 0; i < tsix; i++) cout << "1 2 6\n";
    for (i = 0; i < ttsix; i++) cout << "1 3 6\n";
  }
}
