#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(8);
  for (int i = 0; i < n; i++) {
    int u;
    cin >> u;
    a[u] += 1;
  }
  vector<vector<int> > v(n / 3, vector<int>(3));
  int cur = 1;
  for (int j = 0; j < n / 3;) {
    if (a[cur] == 0 && cur < 8) {
      cur++;
      continue;
    }
    v[j][0] = cur;
    a[cur]--;
    j++;
  }
  for (int j = 0; j < n / 3;) {
    if (a[cur] == 0 && cur < 8) {
      cur++;
      continue;
    }
    if (cur <= v[j][0] || cur % v[j][0] != 0) {
      cout << -1 << '\n';
      return 0;
    }
    v[j][1] = cur;
    a[cur]--;
    j++;
  }
  for (int j = 0; j < n / 3;) {
    if (a[cur] == 0 && cur < 8) {
      cur++;
      continue;
    }
    if (cur <= v[j][1] || cur % v[j][1] != 0) {
      cout << -1 << '\n';
      return 0;
    }
    v[j][2] = cur;
    a[cur]--;
    j++;
  }
  for (int i = 0; i < n / 3; i++) {
    for (int j = 0; j < 3; j++) {
      cout << v[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}
