#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
const int maxn = (int)1e5 + 1;
long long inf = 1LL << 60;
const double eps = 1e-9;
using namespace std;
template <class N>
inline void read(N &n) {
  N x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  n = x * f;
}
int a[8];
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[t]++;
    if (t == 1 || t == 2 || t == 3 || t == 6 || t == 4)
      continue;
    else
      cout << -1, exit(0);
  }
  int x = a[3];
  int y = a[4];
  int z = a[6] - a[3];
  if (a[1] != x + y + z || y + z != a[2] || x < 0 || y < 0 || z < 0)
    cout << -1, exit(0);
  for (int i = 0; i < x; i++) cout << "1 3 6\n";
  for (int i = 0; i < y; i++) cout << "1 2 4\n";
  for (int i = 0; i < z; i++) cout << "1 2 6\n";
  return 0;
}
