#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100000];
  int b[100000];
  vector<long> v;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  int s = 0;
  while (b[1] >= 1 && b[2] >= 1 && b[4] >= 1) {
    v.push_back(1);
    v.push_back(2);
    v.push_back(4);
    b[1]--;
    b[2]--;
    b[4]--;
    s++;
  }
  while (b[1] >= 1 && b[2] >= 1 && b[6] >= 1) {
    v.push_back(1);
    v.push_back(2);
    v.push_back(6);
    b[1]--;
    b[2]--;
    b[6]--;
    s++;
  }
  while (b[1] >= 1 && b[3] >= 1 && b[6] >= 1) {
    v.push_back(1);
    v.push_back(3);
    v.push_back(6);
    b[1]--;
    b[3]--;
    b[6]--;
    s++;
  }
  if (s == 0 || s != n / 3)
    cout << "-1";
  else {
    for (int i = 0; i < v.size(); i += 3)
      cout << v[i] << " " << v[i + 1] << " " << v[i + 2] << endl;
  }
  return 0;
}
