#include <bits/stdc++.h>
const double pi = 3.141592653589793238462;
const double eps = 1e-10;
using namespace std;
int cnt[10];
int t[33334][3];
int main() {
  int i, j, k, n, m, tc;
  ios_base::sync_with_stdio(false);
  cin >> n;
  m = n;
  while (m--) {
    cin >> i;
    cnt[i]++;
  }
  i = 0;
  if (cnt[1] + cnt[2] + cnt[3] + cnt[4] + cnt[6] == n) {
    while (cnt[1] && cnt[2] && cnt[4]) {
      t[i][0] = 1;
      t[i][1] = 2;
      t[i][2] = 4;
      i++;
      cnt[1]--;
      cnt[2]--;
      cnt[4]--;
    }
    while (cnt[1] && cnt[2] && cnt[6]) {
      t[i][0] = 1;
      t[i][1] = 2;
      t[i][2] = 6;
      i++;
      cnt[1]--;
      cnt[2]--;
      cnt[6]--;
    }
    while (cnt[1] && cnt[3] && cnt[6]) {
      t[i][0] = 1;
      t[i][1] = 3;
      t[i][2] = 6;
      i++;
      cnt[1]--;
      cnt[3]--;
      cnt[6]--;
    }
  }
  if (n / 3 != i)
    cout << "-1" << endl;
  else {
    for (j = 0; j < n / 3; j++)
      cout << t[j][0] << " " << t[j][1] << " " << t[j][2] << endl;
  }
  return 0;
}
