#include <bits/stdc++.h>
using namespace std;
int a[8];
int main() {
  int n, temp;
  cin >> n;
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) {
    cin >> temp;
    a[temp]++;
  }
  if (a[1] != n / 3 || (a[2] + a[3]) != n / 3 || (a[4] + a[6]) != n / 3 ||
      a[3] > a[6] || a[4] > a[2] || (a[5] + a[7]) > 0)
    cout << -1 << endl;
  else {
    for (int i = 0; i < a[4]; i++) cout << 1 << ' ' << 2 << ' ' << 4 << endl;
    for (int i = 0; i < a[2] - a[4]; i++)
      cout << 1 << ' ' << 2 << ' ' << 6 << endl;
    for (int i = 0; i < a[3]; i++) cout << 1 << ' ' << 3 << ' ' << 6 << endl;
  }
  return 0;
}
