#include <bits/stdc++.h>
using namespace std;
int main() {
  int count[8] = {0}, x, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    count[x] += 1;
  }
  if (count[5] == 0 && count[7] == 0 && count[4] <= count[2] &&
      count[3] <= count[6] && count[2] == count[4] + count[6] - count[3] &&
      count[1] == count[3] + count[2]) {
    for (int i = 0; i < count[4]; i++) {
      cout << 1 << " " << 2 << " " << 4;
      cout << endl;
    }
    int temp = 0;
    temp = count[2] - count[4];
    for (int i = 0; i < temp; i++) {
      cout << 1 << " " << 2 << " " << 6;
      cout << endl;
    }
    for (int i = 0; i < count[3]; i++) {
      cout << 1 << " " << 3 << " " << 6;
      cout << endl;
    }
  } else {
    printf("-1\n");
  }
  return 0;
}
