#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 1 << 28;
const long long INFL = 1LL << 62;
string res[] = {"NO", "YES"};
int main() {
  int n, x;
  vector<int> va, vb, vc;
  multiset<int> ms;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    ms.insert(x);
  }
  bool con = 1;
  while (!ms.empty() && con) {
    if (ms.find(1) != ms.end()) {
      va.push_back(1);
      if (ms.find(2) != ms.end()) {
        vb.push_back(2);
        if (ms.find(4) != ms.end()) {
          vc.push_back(4);
          ms.erase(ms.find(4));
          ms.erase(ms.find(2));
          ms.erase(ms.find(1));
        } else if (ms.find(6) != ms.end()) {
          vc.push_back(6);
          ms.erase(ms.find(6));
          ms.erase(ms.find(2));
          ms.erase(ms.find(1));
        } else {
          con = 0;
          break;
        }
      } else if (ms.find(3) != ms.end()) {
        vb.push_back(3);
        if (ms.find(6) != ms.end()) {
          vc.push_back(6);
          ms.erase(ms.find(6));
          ms.erase(ms.find(3));
          ms.erase(ms.find(1));
        } else {
          con = 0;
          break;
        }
      } else {
        con = 0;
        break;
      }
    } else {
      con = 0;
      break;
    }
  }
  if (con) {
    for (int i = 0; i < n / 3; ++i)
      cout << va[i] << " " << vb[i] << " " << vc[i] << endl;
  } else
    cout << -1 << endl;
}
