#include <bits/stdc++.h>
using namespace std;
const int NMax = 110000;
int N, cnt[10];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  if (cnt[5] > 0 || cnt[7] > 0) {
    puts("-1");
    return 0;
  }
  int x = min(min(cnt[1], cnt[2]), cnt[4]);
  cnt[1] -= x;
  cnt[2] -= x;
  cnt[4] -= x;
  int y = min(min(cnt[1], cnt[3]), cnt[6]);
  cnt[1] -= y;
  cnt[3] -= y;
  cnt[6] -= y;
  int z = min(min(cnt[1], cnt[2]), cnt[6]);
  cnt[1] -= z;
  cnt[2] -= z;
  cnt[6] -= z;
  if (x * 3 + y * 3 + z * 3 < N)
    puts("-1");
  else {
    for (int i = 1; i <= x; i++) puts("1 2 4");
    for (int i = 1; i <= y; i++) puts("1 3 6");
    for (int i = 1; i <= z; i++) puts("1 2 6");
  }
  return 0;
}
