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