#include <bits/stdc++.h>
using namespace std;
int j[10], n;
int main() {
  cin >> n;
  memset(j, 0, sizeof(j));
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    j[x]++;
  }
  int cnt = 0;
  for (int i = 1; i < 8; i++) {
    if (j[i] > 0) cnt++;
  }
  if (j[1] + j[2] + j[3] + j[6] + j[4] == n) {
    if (j[3] > 0) {
      int s = j[3];
      if (j[6] < j[3]) {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (j[2] > 0) {
      int s = j[2];
      if (j[2] > j[4] + j[6]) {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (j[4] > 0) {
      int s = j[4];
      if (j[4] > j[2]) {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (j[6] > 0) {
      int s = j[6];
      if (j[6] > j[1] + j[2] + j[3]) {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (j[1] > 0) {
      int s = j[1];
      if (j[1] != j[4] + j[6]) {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (j[1] == 0) {
      cout << "-1" << endl;
      return 0;
    }
    for (int i = 0; i < j[4] && j[1] > 0; i++) {
      cout << "1 2 4" << endl;
      j[1]--;
      j[2]--;
    }
    for (int i = 0; i < j[2] && j[1] > 0; i++) {
      cout << "1 2 6" << endl;
      j[1]--;
      j[6]--;
    }
    for (int i = 0; i < j[3] && j[1] > 0; i++) cout << "1 3 6" << endl;
  } else
    cout << "-1" << endl;
}
