#include <bits/stdc++.h>
using namespace std;
int a[999999];
int main() {
  int n, m, k, one = 0, two = 0, three = 0, four = 0, six = 0, c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    if (m == 1)
      one++;
    else if (m == 2)
      two++;
    else if (m == 3)
      three++;
    else if (m == 4)
      four++;
    else if (m == 6)
      six++;
    else
      c = 1;
  }
  if (c == 1)
    cout << -1 << endl;
  else if (one != n / 3)
    cout << -1 << endl;
  else if (two + three != n / 3)
    cout << -1 << endl;
  else if (six < three)
    cout << -1 << endl;
  else {
    for (int i = 0; i < n / 3; i++) {
      cout << 1 << " ";
      if (two) {
        cout << 2 << " ";
        two--;
        if (four) {
          cout << 4 << endl;
          four--;
        } else if (six) {
          cout << 6 << endl;
          six--;
        }
      } else if (three) {
        cout << 3 << " ";
        three--;
        if (six) {
          cout << 6 << endl;
          six--;
        }
      }
    }
  }
  return 0;
}
