#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long llinf = 1e18;
const long long nax = 0;
long long n, s24 = 0, s26 = 0, s36 = 0;
vector<long long> arr(100005);
map<long long, long long> cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    cnt[arr[i]]++;
  }
  if (cnt[1] < n / 3) {
    cout << "-1" << '\n';
  } else if (cnt[2] + cnt[3] < n / 3) {
    cout << "-1" << '\n';
  } else if (cnt[4] + cnt[6] < n / 3) {
    cout << "-1" << '\n';
  } else {
    long long mn = min({cnt[2], cnt[4]});
    s24 += mn;
    cnt[1] -= mn;
    cnt[2] -= mn;
    cnt[4] -= mn;
    mn = min({cnt[2], cnt[6]});
    s26 += mn;
    cnt[1] -= mn;
    cnt[2] -= mn;
    cnt[6] -= mn;
    mn = min({cnt[3], cnt[6]});
    s36 += mn;
    cnt[1] -= mn;
    cnt[3] -= mn;
    cnt[6] -= mn;
    if (cnt[1] || cnt[2] || cnt[3] || cnt[4] || cnt[6]) {
      cout << "-1" << '\n';
      return 0;
    }
    while (s24--) {
      cout << 1 << ' ' << 2 << ' ' << 4 << '\n';
    }
    while (s26--) {
      cout << 1 << ' ' << 2 << ' ' << 6 << '\n';
    }
    while (s36--) {
      cout << 1 << ' ' << 3 << ' ' << 6 << '\n';
    }
  }
}
