#include <bits/stdc++.h>
using namespace std;
const double e = 1e-9;
const int maxN = 1e5 + 1;
int a[maxN];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    if (t == 5 || t == 7) {
      cout << -1;
      return;
    }
    a[t]++;
  }
  if (a[1] == n / 3 && a[4] + a[6] == n / 3 && a[2] + a[3] == n / 3 &&
      a[3] <= a[6]) {
    for (int i = 0; i < n / 3; ++i) {
      cout << 1 << ' ';
      if (a[3]) {
        cout << "3 ";
        a[3]--;
        cout << 6 << endl;
        a[6]--;
        continue;
      }
      cout << "2 ";
      if (a[4]) {
        cout << 4 << endl;
        a[4]--;
        continue;
      }
      cout << 6 << endl;
    }
  } else
    cout << -1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
