#include <bits/stdc++.h>
const int maxN = (int)3e5 + 100;
const int MOD = (int)100000000;
const unsigned int Modu = 1000000007;
using namespace std;
const int N = 6e5 + 100;
int dp[222222][26];
vector<int> v[222222];
pair<int, int> p[N];
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
set<long long> st;
void dfs(string s) {
  if (s.length() > 10) {
    return;
  }
  long long num = stoll(s);
  st.insert(num);
  dfs(s + "4");
  dfs(s + "7");
}
int solve() {
  int n;
  cin >> n;
  int pref[7] = {0};
  for (int i = 0; i < (n); ++i) {
    int x;
    cin >> x;
    pref[x - 1]++;
  }
  n /= 3;
  if (pref[0] != n || pref[4] > 0 || pref[6] > 0 || pref[2] > pref[5] ||
      (pref[1] + pref[2]) != (pref[3] + pref[5])) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < (pref[2]); ++i) {
    cout << "1 3 6" << endl;
  }
  pref[5] -= pref[2];
  for (int i = 0; i < (pref[3]); ++i) {
    cout << "1 2 4" << endl;
  }
  for (int i = 0; i < (pref[5]); ++i) {
    cout << "1 2 6" << endl;
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
