#include <bits/stdc++.h>
using namespace std;
int x;
int a[33];
int f[11][11][11];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    ++a[x];
  }
  if (a[5] > 0 || a[7] > 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= 6; ++i)
    if (a[i] > n / 3) {
      cout << -1 << endl;
      return 0;
    }
  if (a[3] > 0) {
    if (a[1] < a[3] || a[6] < a[3]) {
      cout << -1 << endl;
      return 0;
    }
    f[1][3][6] = a[3];
    a[1] -= a[3];
    a[6] -= a[3];
    a[3] = 0;
  }
  if (a[6] > 0) {
    if (a[1] < a[6] || a[2] < a[6]) {
      cout << -1 << endl;
      return 0;
    }
    f[1][2][6] = a[6];
    a[1] -= a[6];
    a[2] -= a[6];
    a[6] = 0;
  }
  if (a[4] > 0) {
    if (a[1] < a[4] || a[2] < a[4]) {
      cout << -1 << endl;
      return 0;
    }
    f[1][2][4] = a[4];
    a[1] -= a[4];
    a[2] -= a[4];
    a[4] = 0;
  }
  for (int i = 1; i <= 7; ++i)
    if (a[i] > 0) {
      cout << -1 << endl;
      return 0;
    }
  for (int i = 0; i < 7; ++i)
    for (int j = 0; j < 7; ++j)
      for (int k = 0; k < 7; ++k)
        for (int u = 0; u < f[i][j][k]; ++u) printf("%d %d %d\n", i, j, k);
}
