#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp;
  int e[100000];
  int c[8];
  memset(e, 8, sizeof(e));
  cin >> n;
  temp = n / 3;
  for (int i = 0; i < n; i++) {
    cin >> e[i];
    c[e[i]]++;
  }
  sort(e, e + 99999);
  if (c[1] == temp && c[5] == 0 && c[7] == 0)
    if (c[2] >= c[4] && (c[2] + c[3]) == (c[4] + c[6])) {
      for (int i = 0; i < temp; i++)
        cout << e[i] << " " << e[temp + i] << " " << e[temp * 2 + i] << endl;
    } else
      cout << "-1" << endl;
  else
    cout << "-1" << endl;
  return 0;
}
