#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, i;
  cin >> n;
  vector<long long int> v(n);
  map<long long int, long long int> mp;
  mp[1] = 0;
  mp[2] = 0;
  mp[3] = 0;
  mp[4] = 0;
  mp[6] = 0;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  if (mp[1] == n / 3 && (mp[2] + mp[3] == n / 3) && (mp[4] + mp[6] == n / 3) &&
      mp[6] >= mp[3] && mp[2] >= mp[4]) {
    for (i = 0; i < mp[3]; i++) cout << "1 3 6" << endl;
    for (i = 0; i < mp[4]; i++) cout << "1 2 4" << endl;
    for (i = 0; i < n / 3 - (mp[3] + mp[4]); i++) cout << "1 2 6" << endl;
  } else
    cout << "-1";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
