#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> data, res;
  int cnt = n / 3;
  map<int, int> mp;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
    if (a == 5 || a == 7)
      flag = true;
    else if (mp[a] > cnt)
      flag = true;
    else
      data.push_back(a);
  }
  if (flag) {
    cout << "-1";
    return 0;
  }
  int z = 0;
  sort(data.begin(), data.end());
  for (int i = 0; i < data.size(); i++) {
    if (data[i] == 1 && mp[data[i]]) {
      if (mp[2] && mp[4]) {
        res.push_back(1);
        res.push_back(2);
        res.push_back(4);
        mp[2]--;
        mp[4]--;
        mp[1]--;
        z++;
      } else if (mp[3] && mp[6]) {
        res.push_back(1);
        res.push_back(3);
        res.push_back(6);
        mp[3]--;
        mp[6]--;
        mp[1]--;
        z++;
      } else if (mp[2] && mp[6]) {
        res.push_back(1);
        res.push_back(2);
        res.push_back(6);
        mp[2]--;
        mp[6]--;
        mp[1]--;
        z++;
      }
    }
  }
  if (z != cnt) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < res.size(); i++) {
    cout << res[i] << " ";
    if ((i + 1) % 3 == 0) cout << '\n';
  }
  return 0;
}
