#include <bits/stdc++.h>
using namespace std;
int cnt[6];
const int N = 1e5;
int a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int y;
    cin >> y;
    ++cnt[y];
  }
  if (n / 3 == cnt[1] && n / 3 == cnt[2] + cnt[3] && n / 3 == cnt[4] + cnt[6] &&
      cnt[3] <= cnt[6]) {
    for (int i = 1; i <= n / 3; i++) {
      cout << "1"
           << " ";
      if (cnt[2] > 0) {
        cout << 2 << " ";
        --cnt[2];
      } else
        cout << "3"
             << " ";
      if (cnt[4] > 0) {
        cout << 4 << "\n";
        --cnt[4];
      } else
        cout << "6"
             << " ";
      cout << "\n";
    }
  } else
    cout << -1;
}
