#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, o = 0, t = 0, th = 0, f = 0, s = 0;
  cin >> n;
  if (n % 3 != 0) {
    cout << -1;
    return 0;
    ;
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1) o++;
    if (x == 2) t++;
    if (x == 3) th++;
    if (x == 4) f++;
    if (x == 6) s++;
  }
  int v = n / 3;
  int x = 0, a = 0, b = 0, c = 0;
  for (int i = 0; i < v; i++) {
    if (o && t && f) {
      o--;
      t--;
      f--;
      a++;
      x++;
    } else if (o && th && s) {
      o--;
      th--;
      s--;
      b++;
      x++;
    } else if (o && t && s) {
      o--;
      t--;
      s--;
      c++;
      x++;
    }
  }
  if (x == v) {
    while (a > 0) {
      cout << "1 2 4" << endl;
      a--;
    }
    while (b > 0) {
      cout << "1 3 6" << endl;
      b--;
    }
    while (c > 0) {
      cout << "1 2 6" << endl;
      c--;
    }
  } else {
    cout << -1;
  }
  return 0;
  ;
}
