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