#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n;
  int hash[8] = {0};
  int y = n / 3;
  while (n--) {
    cin >> k;
    hash[k]++;
  }
  if (hash[1] == y && hash[2] + hash[3] == y && hash[4] + hash[6] == y &&
      hash[2] >= hash[4] && hash[6] >= hash[3]) {
    while (hash[4]--) {
      hash[2]--;
      cout << "1 2 4\n";
    }
    while (hash[3]--) {
      cout << "1 3 6\n";
    }
    while (hash[2]--) {
      cout << "1 2 6\n";
    }
  } else
    cout << "-1";
  return 0;
}
