#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INF_LL = numeric_limits<ll>::max();
void solve() {
  vector<int> cnts(8, 0);
  int n;
  cin >> n;
  bool res = true;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 5 || t == 7)
      res = false;
    else
      cnts[t]++;
  }
  int t1 = 0;
  int t2 = 0;
  int t3 = 0;
  while (cnts[1] > 0 && cnts[2] > 0 && cnts[4] > 0) {
    cnts[1]--;
    cnts[2]--;
    cnts[4]--;
    t1++;
  }
  while (cnts[1] > 0 && cnts[2] > 0 && cnts[6] > 0) {
    cnts[1]--;
    cnts[2]--;
    cnts[6]--;
    t2++;
  }
  while (cnts[1] > 0 && cnts[3] > 0 && cnts[6] > 0) {
    cnts[1]--;
    cnts[3]--;
    cnts[6]--;
    t3++;
  }
  if (t1 == 0 && t2 == 0 && t3 == 0) res = false;
  if (!res || (t1 + t2 + t3) * 3 != n) {
    cout << -1;
    return;
  }
  for (int i = 0; i < t1; i++) cout << "1 2 4" << endl;
  for (int i = 0; i < t2; i++) cout << "1 2 6" << endl;
  for (int i = 0; i < t3; i++) cout << "1 3 6" << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
