#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, a, b, c, d, i, j, k, l, m = 0;
  vector<long long int> vec;
  map<long long int, long long int> mp;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> b;
    if (b == 7 || b == 5) m = 1;
    vec.push_back(b);
    mp[b]++;
  }
  if (m == 1) {
    cout << "-1" << endl;
    return 0;
  }
  if (n == 3) {
    sort(vec.begin(), vec.end());
    if ((vec[0] == 1 && vec[1] == 2 && vec[2] == 4) ||
        (vec[0] == 1 && vec[1] == 2 && vec[2] == 6) ||
        (vec[0] == 1 && vec[1] == 3 && vec[2] == 6))
      cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
    else
      cout << "-1" << endl;
    return 0;
  }
  if (mp[2] >= mp[4]) {
    if (mp[1] == (mp[2] + mp[3]) && (mp[1] == (mp[4] + mp[6]))) {
      for (i = 1; i <= n / 3; i++) {
        if (mp[3] > 0 && mp[6] > 0) {
          cout << "1 3 6" << endl;
          mp[3]--;
          mp[6]--;
        } else if (mp[2] > 0 && mp[6] > 0) {
          cout << "1 2 6" << endl;
          mp[2]--;
          mp[6]--;
        } else if (mp[2] > 0 && mp[4] > 0) {
          cout << "1 2 4" << endl;
          mp[2]--;
          mp[4]--;
        }
      }
    } else
      cout << "-1" << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
