#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x, one = 0, to = 0, tre = 0, fr = 0, sx = 0, wa = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 1)
      one++;
    else if (x == 2)
      to++;
    else if (x == 3)
      tre++;
    else if (x == 4)
      fr++;
    else if (x == 6)
      sx++;
    else
      wa++;
  }
  if (one != n / 3 || wa > 0)
    cout << -1;
  else {
    int mn = min({one, to, fr});
    one -= mn;
    to -= mn;
    fr -= mn;
    int mn1 = min({one, to, sx});
    one -= mn1;
    to -= mn1;
    sx -= mn1;
    int mn2 = min({one, tre, sx});
    if ((mn + mn1 + mn2) == n / 3) {
      for (int i = 0; i < mn; i++) cout << 1 << " " << 2 << " " << 4 << endl;
      for (int i = 0; i < mn1; i++) cout << 1 << " " << 2 << " " << 6 << endl;
      for (int i = 0; i < mn2; i++) cout << 1 << " " << 3 << " " << 6 << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
