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