#include <bits/stdc++.h>
using namespace std;
signed main() {
  int N;
  cin >> N;
  vector<int> A(7);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A[x - 1]++;
  }
  vector<tuple<int, int, int>> ans;
  for (int i = 0; i < 7; i++) {
    if (A[i]) {
      for (int j = i + 1; j < 7; j++) {
        if (A[j]) {
          if ((j + 1) % (i + 1) == 0) {
            for (int k = j + 1; k < 7; k++) {
              if (A[k]) {
                if ((k + 1) % (j + 1) == 0) {
                  int tmp = min(A[i], min(A[j], A[k]));
                  A[i] -= tmp, A[j] -= tmp, A[k] -= tmp;
                  while (tmp--) ans.push_back(make_tuple(i + 1, j + 1, k + 1));
                  i = -1, j = k = 6;
                }
              }
            }
          }
        }
      }
    }
  }
  if (ans.size() != N / 3)
    cout << "-1\n";
  else
    for (int i = 0; i < ans.size(); i++)
      cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i])
           << endl;
  return 0;
}
bool cp(pair<long long, long long> x, pair<long long, long long> y) {
  return x.first * y.second > y.first * x.second;
}
long long mn = 1e15;
void sol(long long N, long long ans = 0, int fours = 0, int sevens = 0) {
  if ((ans >= N && fours == sevens) || ans >= N * 100) {
    mn = min(mn, ans);
    return;
  }
  sol(N, ans * 10 + 4, fours + 1, sevens);
  sol(N, ans * 10 + 7, fours, sevens + 1);
}
