#include <bits/stdc++.h>
using namespace std;
int counts[8];
int main() {
  int n, t, i;
  cin >> n;
  for (int k = 0; k < n; k++) {
    cin >> t;
    counts[t]++;
  }
  vector<vector<int> > groups;
  while (true) {
    vector<int> row;
    for (i = 1; i <= 7; i++) {
      if (counts[i] != 0) {
        row.push_back(i);
        counts[i]--;
        break;
      }
    }
    i++;
    for (; i <= 7; i++) {
      if (counts[i] > 0) {
        if (i % row[row.size() - 1] == 0) {
          row.push_back(i);
          counts[i]--;
          if (row.size() == 3) break;
        }
      }
    }
    if (row.size() < 3) {
      cout << -1 << endl;
      return 0;
    }
    groups.push_back(row);
    if (groups.size() == n / 3) break;
  }
  for (i = 0; i < groups.size(); i++) {
    for (int j = 0; j < groups[i].size(); j++) {
      cout << groups[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
