#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000ll;
vector<int> v(8, 0);
int main() {
  int n, f, s, mmax = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> f;
    v[f]++;
  }
  if (v[5] > 0 || v[7] > 0) {
    cout << -1 << endl;
    return 0;
  }
  if (v[1] != (v[2] + v[3])) {
    cout << -1 << endl;
    return 0;
  }
  if (v[2] < v[4]) {
    cout << -1 << endl;
    return 0;
  }
  if ((v[2] + v[3]) != (v[4] + v[6])) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n / 3; i++) {
    if (v[4]) {
      printf("1 2 4\n");
      v[4]--;
      v[2]--;
      continue;
    }
    if (v[2]) {
      printf("1 2 6\n");
      v[6]--;
      v[2]--;
      continue;
    }
    printf("1 3 6\n");
  }
  return 0;
}
