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