#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
inline void mn(T &x, V y) {
  if (y < x) x = y;
}
template <typename T, typename V>
inline void mx(T &x, V y) {
  if (x < y) x = y;
}
int main() {
  int n;
  cin >> n;
  int a;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a;
    mp[a]++;
  }
  if (mp.count(7) || mp.count(5)) {
    cout << -1 << endl;
  } else {
    vector<string> v;
    if (mp.count(1) && mp.count(2) && mp.count(4)) {
      int k = min(mp[1], min(mp[2], mp[4]));
      for (int i = 0; i < k; i++) v.push_back("1 2 4");
      mp[1] -= k;
      mp[2] -= k;
      mp[4] -= k;
    }
    if (mp.count(1) && mp.count(2) && mp.count(6)) {
      int k = min(mp[1], min(mp[2], mp[6]));
      for (int i = 0; i < k; i++) v.push_back("1 2 6");
      mp[1] -= k;
      mp[2] -= k;
      mp[6] -= k;
    }
    if (mp.count(1) && mp.count(3) && mp.count(6)) {
      int k = min(mp[1], min(mp[3], mp[6]));
      for (int i = 0; i < k; i++) v.push_back("1 3 6");
      mp[1] -= k;
      mp[3] -= k;
      mp[6] -= k;
    }
    int f = 1;
    for (auto x : mp) {
      if (x.second < 0 || x.second) {
        f = 0;
        break;
      }
    }
    if (f) {
      for (int i = 0; i < v.size(); i++) {
        cout << v[i] << endl;
      }
    } else
      cout << -1 << endl;
  }
}
