#include <bits/stdc++.h>
using namespace std;
int n, a, cnt[9];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    cnt[a]++;
  }
  bool judge = (cnt[4] <= cnt[2]) && (cnt[3] <= cnt[6]);
  if (cnt[1] != n / 3) judge = false;
  if (cnt[2] + cnt[3] != n / 3) judge = false;
  if (cnt[4] + cnt[6] != n / 3) judge = false;
  if (!judge)
    printf("-1\n");
  else {
    for (int i = 1; i <= cnt[4]; i++) printf("1 2 4\n");
    for (int i = 1; i <= cnt[2] - cnt[4]; i++) printf("1 2 6\n");
    for (int i = 1; i <= cnt[3]; i++) printf("1 3 6\n");
  }
  return 0;
}
