#include <bits/stdc++.h>
using namespace std;
int a[100000];
bool b[100000];
int c[3][100000 / 3];
int main() {
  int n;
  while (cin >> n) {
    memset(a, 0, sizeof(a));
    memset(b, true, sizeof(b));
    bool flag = true;
    int sum1 = 0;
    int sum2, sum3;
    sum2 = sum3 = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 5 || a[i] == 7) flag = false;
      if (a[i] == 1) sum1++;
      if (a[i] == 2 || a[i] == 3) sum2++;
      if (a[i] == 4 || a[i] == 6) sum3++;
    }
    if (sum1 != n / 3 || sum2 != n / 3 || sum3 != n / 3) flag = false;
    if (!flag)
      cout << "-1" << endl;
    else {
      sort(a, a + n);
      for (int i = 0; i < n / 3; i++) {
        c[0][i] = a[i];
        c[1][i] = a[i + n / 3];
        c[2][i] = a[i + 2 * n / 3];
        if (c[1][i] == 3 && c[2][i] == 4) flag = false;
      }
      if (flag) {
        for (int i = 0; i < n / 3; i++)
          cout << c[0][i] << " " << c[1][i] << "  " << c[2][i] << endl;
      } else
        cout << "-1" << endl;
    }
  }
  return 0;
}
