#include <bits/stdc++.h>
using namespace std;
const int max = 200005;
string s[3] = {"1 2 4", "1 2 6", "1 3 6"};
int a[8], b[4];
int main() {
  int N, n;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> n;
    a[n]++;
    if (n == 5 || n == 7) {
      cout << -1;
      return 0;
    }
  }
  b[2] = a[3];
  b[1] = a[6] - a[3];
  b[0] = a[4];
  if (a[1] != N / 3) {
    cout << -1;
    return 0;
  }
  if (a[3] > a[6]) {
    cout << -1;
    return 0;
  }
  a[6] -= a[3];
  if (a[6] > a[2]) {
    cout << -1;
    return 0;
  }
  a[2] -= a[6];
  if (a[2] != a[4]) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < 3; i++)
    while (b[i]--) cout << s[i] << endl;
  return 0;
}
