#include <bits/stdc++.h>
int a[100005];
int cmp(const void *a, const void *b) {
  int aa = *(int *)a, bb = *(int *)b;
  return aa - bb;
}
int main() {
  int n, i, flag = 0;
  int num1, num2, num3, num4, num6;
  num1 = num2 = num3 = num4 = num6 = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  qsort(a + 1, n, sizeof(int), cmp);
  for (i = 1; i <= n / 3; i++) {
    if (a[i] == 1)
      num1++;
    else
      flag = 1;
  }
  for (i = n / 3 + 1; i <= n / 3 * 2; i++) {
    if (a[i] == 3)
      num3++;
    else if (a[i] == 2)
      num2++;
    else
      flag = 1;
  }
  for (i = n / 3 * 2 + 1; i <= n; i++) {
    if (a[i] == 6)
      num6++;
    else if (a[i] == 4)
      num4++;
    else
      flag = 1;
  }
  if (num3 != n / 3 - num2 || num2 < num4) flag = 1;
  if (flag == 1)
    printf("-1\n");
  else {
    for (i = 1; i <= n / 3; i++) {
      if (num2 > 0) {
        if (num4 > 0) {
          printf("1 2 4\n");
          num4--;
        } else {
          printf("1 2 6\n");
          num6--;
        }
        num2--;
      } else
        printf("1 3 6\n");
    }
  }
  return 0;
}
