#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
void debug(vector<T> vec) {
  for (int i = 0; i < vec.size(); i++) cerr << vec[i] << " ";
  cerr << "\n";
}
template <class T>
void debug(vector<vector<T> > vec) {
  for (int i = 0; i < vec.size(); i++) {
    for (int ii = 0; ii < vec[i].size(); ii++) cerr << vec[i][ii] << " ";
    cerr << "\n";
  }
}
pair<int, int> dirs[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
void solve() {
  vector<int> v(8, 0);
  int n;
  cin >> n;
  int i;
  for (int i = 0; i < n; i++) {
    int va;
    cin >> va;
    v[va]++;
  }
  if (v[7] > 0 || v[5] > 0) {
    cout << -1 << "\n";
    return;
  }
  vector<int> c = v;
  c[1] -= c[3];
  c[6] -= c[3];
  if (c[6] < 0 || c[3] < 0) {
    cout << -1 << "\n";
    return;
  }
  c[1] -= c[4];
  c[2] -= c[4];
  if (c[1] < 0 || c[2] < 0) {
    cout << -1 << "\n";
    return;
  }
  if (c[1] == c[2] && c[2] == c[6]) {
    while (c[3]-- > 0)
      cout << "1 3 6"
           << "\n";
    while (c[4]-- > 0)
      cout << "1 2 4"
           << "\n";
    while (c[1]-- > 0)
      cout << "1 2 6"
           << "\n";
  } else
    cout << -1 << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin.tie(NULL);
  int testcases = 1;
  while (testcases-- != 0) {
    solve();
  }
}
