#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[8] = {0}, t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    arr[t]++;
  }
  arr[6] -= arr[3];
  arr[1] -= arr[3];
  if (arr[6] < 0 || arr[1] < 0) {
    cout << -1 << endl;
    return 0;
  }
  if (arr[1] != arr[2] || arr[1] != arr[6] + arr[4] || arr[7] || arr[5]) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < arr[4]; i++) cout << "1 2 4" << endl;
  for (int i = 0; i < arr[6]; i++) cout << "1 2 6" << endl;
  for (int i = 0; i < arr[3]; i++) cout << "1 3 6" << endl;
  return 0;
}
