#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  vector<int> ans;
  while (mp[1] && mp[2] && mp[4]) {
    ans.push_back(1);
    ans.push_back(2);
    ans.push_back(4);
    mp[1]--;
    mp[2]--;
    mp[4]--;
  }
  while (mp[1] && mp[2] && mp[6]) {
    ans.push_back(1);
    ans.push_back(2);
    ans.push_back(6);
    mp[1]--;
    mp[2]--;
    mp[6]--;
  }
  while (mp[1] && mp[3] && mp[6]) {
    ans.push_back(1);
    ans.push_back(3);
    ans.push_back(6);
    mp[1]--;
    mp[3]--;
    mp[6]--;
  }
  if (mp[1] > 0 || mp[2] > 0 || mp[3] > 0 || mp[6] > 0 || mp[7] > 0 ||
      mp[5] > 0) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < ans.size();) {
    for (int j = 0; j < 3; j++) {
      cout << ans[i] << " ";
      i++;
    }
    cout << endl;
  }
  return 0;
}
