#include <bits/stdc++.h>
#pragma comment(linker, "/stack:102400000,102400000")
using namespace std;
int f_abs(int x) { return x < 0 ? -x : x; }
int f_max(int a, int b) { return a > b ? a : b; }
int f_min(int a, int b) { return a < b ? a : b; }
int gcd(int a, int b) {
  while (int t = a % b) a = b, b = t;
  return b;
}
bool isdig(char ch) { return ch >= '0' && ch <= '9'; }
bool isup(char ch) { return ch >= 'A' && ch <= 'Z'; }
bool islow(char ch) { return ch >= 'a' && ch <= 'z'; }
const double eps = 1e-9;
const int N = 100003;
int main() {
  int n, i, cnt[8], t;
  while (~scanf("%d", &n)) {
    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < n; ++i) {
      scanf("%d", &t);
      cnt[t]++;
    }
    bool flag;
    if (cnt[5] || cnt[7])
      flag = false;
    else {
      if (cnt[1] == n / 3 && cnt[2] + cnt[3] == n / 3 &&
          cnt[4] + cnt[6] == n / 3 && cnt[6] >= cnt[3])
        flag = true;
      else
        flag = false;
    }
    if (!flag)
      printf("-1\n");
    else {
      for (i = 3; i <= n; i += 3) {
        if (cnt[2] && cnt[4]) {
          cnt[2]--;
          cnt[4]--;
          printf("1 2 4\n");
        } else if (cnt[2] && cnt[6]) {
          cnt[2]--;
          cnt[6]--;
          printf("1 2 6\n");
        } else {
          printf("1 3 6\n");
        }
      }
    }
  }
  return 0;
}
