#include <bits/stdc++.h>
using namespace std;
int cnt[8], n;
void solv() {
  if (cnt[5] || cnt[7]) {
    printf("-1\n");
    return;
  }
  if (cnt[1] != cnt[2] + cnt[3]) {
    printf("-1\n");
    return;
  }
  if (cnt[3] > cnt[6]) {
    printf("-1\n");
    return;
  }
  if (cnt[2] + cnt[3] != cnt[4] + cnt[6]) {
    printf("-1\n");
    return;
  }
  for (int i = 0; i < cnt[3]; i++) printf("1 3 6\n");
  cnt[6] -= cnt[3];
  cnt[3] = 0;
  for (int i = 0; i < cnt[6]; i++) printf("1 2 6\n");
  cnt[2] -= cnt[6];
  cnt[6] = 0;
  for (int i = 0; i < cnt[4]; i++) printf("1 2 4\n");
  cnt[2] -= cnt[4];
  cnt[4] = 0;
  for (int i = 1; i <= 7; i++)
    if (cnt[i] < 0)
      while (1)
        ;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  solv();
  return 0;
}
