#include <bits/stdc++.h>
using namespace std;
int mini(int a, int b, int c) {
  int k = 0;
  if (a <= b && a <= c)
    k = a;
  else if (b <= a && b <= c)
    k = b;
  else if (c <= b && c <= a)
    k = c;
  return k;
}
int main() {
  int t;
  cin >> t;
  int arr[t];
  int arrs[8] = {0};
  int count = 0;
  int otf = 0, ots = 0, oths = 0, q = 0;
  for (int i = 0; i < t; i++) {
    cin >> arr[i];
    if (arr[i] == 5 || arr[i] == 7) q++;
    arrs[arr[i]]++;
  }
  if (q != 0)
    cout << "-1";
  else {
    if (arrs[1] != 0 && arrs[2] != 0 && arrs[4] != 0) {
      otf = mini(arrs[1], arrs[2], arrs[4]);
      count += (otf * 3);
      arrs[1] -= otf;
      arrs[2] -= otf;
      arrs[4] -= otf;
    }
    if (arrs[1] != 0 && arrs[2] != 0 && arrs[6] != 0) {
      ots = mini(arrs[1], arrs[2], arrs[6]);
      arrs[1] -= ots;
      arrs[2] -= ots;
      arrs[6] -= ots;
      count += (ots * 3);
    }
    if (arrs[1] != 0 && arrs[3] != 0 && arrs[6] != 0) {
      oths = mini(arrs[1], arrs[3], arrs[6]);
      arrs[1] -= oths;
      arrs[3] -= oths;
      arrs[6] -= oths;
      count += (oths * 3);
    }
    if (count == 0)
      cout << "-1";
    else if (count != t)
      cout << "-1";
    else {
      for (int i = 0; i < otf; i++) cout << "1 2 4 \n";
      for (int i = 0; i < ots; i++) cout << "1 2 6 \n";
      for (int i = 0; i < oths; i++) cout << "1 3 6 \n";
    }
  }
}
