#include <bits/stdc++.h>
using namespace std;
int a[100000], freq[100000];
int main() {
  int n, co1 = 0, co2 = 0, co3;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 5 || a[i] == 7) {
      printf("-1\n");
      return 0;
    }
    freq[a[i]]++;
  }
  if (freq[1] == (n / 3) && freq[2] >= freq[4] && freq[3] <= freq[6] &&
      freq[2] + freq[3] == freq[4] + freq[6]) {
    freq[6] -= freq[3];
    freq[1] -= freq[3];
    co1 += freq[3];
    freq[3] = 0;
    freq[2] -= freq[4];
    freq[1] -= freq[4];
    co2 += freq[4];
    freq[4] = 0;
    co3 = freq[1];
    for (int i = 1; i <= co2; i++) {
      printf("1 2 4\n");
    }
    for (int i = 1; i <= co3; i++) {
      printf("1 2 6\n");
    }
    for (int i = 1; i <= co1; i++) {
      printf("1 3 6\n");
    }
  } else {
    printf("-1\n");
  }
}
