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