#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) {
    long long n, a[8] = {0}, k;
    cin >> n;
    for (int i = 0; i <= n - 1; i++) {
      cin >> k;
      a[k]++;
    }
    if (a[5] > 0 || a[7] > 0 || a[1] != n / 3 || a[3] > a[6] || a[4] > a[2] ||
        ((a[3] + a[2]) != n / 3) || ((a[4] + a[6]) != n / 3)) {
      cout << -1;
      return 0;
    }
    while (a[4]) {
      cout << "1 2 4"
           << "\n";
      a[4]--;
      a[2]--;
    }
    while (a[2]) {
      cout << "1 2 6"
           << "\n";
      a[2]--;
    }
    while (a[3]) {
      cout << "1 3 6" << '\n';
      a[3]--;
    }
  }
  cerr << "Time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
