#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, long long>& a, const pair<int, long long>& b) {
  return a.second > b.second;
}
vector<pair<int, int> > dots;
bool taken[8];
int main() {
  int N;
  cin >> N;
  int a[N];
  vector<int> groups[N / 3];
  for (__typeof(N / 3) i = 0; i < N / 3; i++) {
    groups[i] = vector<int>();
  }
  int dcount[8];
  memset((dcount), 0, sizeof(dcount));
  for (__typeof(N) i = 0; i < N; i++) {
    cin >> a[i];
    bool isGood = false;
    if (a[i] == 1) isGood = true;
    if (a[i] == 2) isGood = true;
    if (a[i] == 3) isGood = true;
    if (a[i] == 4) isGood = true;
    if (a[i] == 6) isGood = true;
    if (!isGood) {
      cout << "-1";
      return 0;
    }
    dcount[a[i]]++;
  }
  if (dcount[1] != N / 3) {
    cout << "-1";
    return 0;
  }
  int g1[N / 3];
  int g2[N / 3];
  int g3[N / 3];
  int gi = 0;
  while (dcount[6] > 0) {
    bool good = false;
    if (dcount[3] > 0) {
      g1[gi] = 6;
      g2[gi] = 3;
      g3[gi] = 1;
      dcount[6]--;
      dcount[1]--;
      dcount[3]--;
      gi++;
      continue;
    }
    if (dcount[2] > 0) {
      g1[gi] = 6;
      g2[gi] = 2;
      g3[gi] = 1;
      dcount[6]--;
      dcount[2]--;
      dcount[1]--;
      gi++;
      continue;
    }
    cout << "-1";
    return 0;
  }
  while (dcount[4] > 0) {
    bool good = false;
    if (dcount[2] > 0) {
      g1[gi] = 4;
      g2[gi] = 2;
      g3[gi] = 1;
      dcount[4]--;
      dcount[2]--;
      dcount[1]--;
      gi++;
      continue;
    }
    cout << "-1";
    return 0;
  }
  for (int i = 1; i <= 7; i++) {
    if (dcount[i] > 0) {
      cout << "-1";
      return 0;
    }
  }
  for (__typeof(N / 3) i = 0; i < N / 3; i++) {
    cout << g3[i] << " " << g2[i] << " " << g1[i] << "\n";
  }
}
