#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b = 0, d, m, n, s, k, sum = 0, t = 0, z, y = 0;
  vector<int> vect, v;
  vector<int>::iterator ip;
  int x1 = 0, x2 = 0, x3 = 0, x4 = 0, x6 = 0;
  v.clear();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 1) {
      x1++;
    } else if (a == 2) {
      x2++;
    } else if (a == 3) {
      x3++;
    } else if (a == 4) {
      x4++;
    } else if (a == 6) {
      x6++;
    }
  }
  if (n > (x1 + x2 + x3 + x4 + x6) || x1 < n / 3 || x4 > x2 || (x2 + x3) < x6) {
    cout << -1;
    exit(0);
  }
  while (x1 > 0 && x2 > 0 && x4 > 0) {
    v.push_back(1);
    v.push_back(2);
    v.push_back(4);
    x1--;
    x2--;
    x4--;
    t = t + 3;
  }
  while (x1 > 0 && x2 > 0 && x6 > 0) {
    v.push_back(1);
    v.push_back(2);
    v.push_back(6);
    x1--;
    x2--;
    x6--;
    t = t + 3;
  }
  while (x1 > 0 && x3 > 0 && x6 > 0) {
    v.push_back(1);
    v.push_back(3);
    v.push_back(6);
    x1--;
    x3--;
    x6--;
    t = t + 3;
  }
  if (n / 3 != t / 3) {
    cout << -1;
    exit(0);
  }
  for (int i = 0; i < t; i++) {
    cout << v[i] << " ";
    if ((i + 1) % 3 == 0) cout << endl;
  }
  return 0;
}
