#include <bits/stdc++.h>
using namespace std;
int p[10];
int min(int a, int b, int c) { return min(min(a, b), c); }
int main() {
  int i, n, x, k, f, a, b, c, d, kk, e;
  while (cin >> n) {
    memset(p, 0, sizeof(p));
    f = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &x);
      p[x]++;
      if (x == 5 || x == 7) f = 1;
    }
    if (f) {
      cout << -1 << endl;
      continue;
    }
    a = p[1], b = p[2], c = p[3], d = p[4], e = p[6];
    f = 0;
    k = min(p[1], p[2], p[4]);
    p[1] -= k;
    p[2] -= k;
    p[4] -= k;
    kk = k * 3;
    k = min(p[1], p[2], p[6]);
    p[1] -= k;
    p[2] -= k;
    p[6] -= k;
    kk += k * 3;
    k = min(p[1], p[3], p[6]);
    kk += k * 3;
    if (kk != n) {
      cout << -1 << endl;
      continue;
    }
    p[1] = a, p[2] = b, p[3] = c, p[4] = d, p[6] = e;
    k = min(p[1], p[2], p[4]);
    p[1] -= k;
    p[2] -= k;
    p[4] -= k;
    for (i = 1; i <= k; i++) {
      printf("1 2 4\n");
    }
    k = min(p[1], p[2], p[6]);
    p[1] -= k;
    p[2] -= k;
    p[6] -= k;
    for (i = 1; i <= k; i++) {
      printf("1 2 6\n");
    }
    k = min(p[1], p[3], p[6]);
    for (i = 1; i <= k; i++) {
      printf("1 3 6\n");
    }
  }
}
