#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x;
  cin >> n;
  int cnt[8] = {0, 0, 0, 0, 0, 0, 0, 0};
  for (int i = 0; i < n; i++) {
    cin >> x;
    cnt[x]++;
  }
  if (cnt[1] == n / 3 && (cnt[2] + cnt[3] == n / 3) &&
      (cnt[4] + cnt[6] == n / 3) && (cnt[2] >= cnt[4])) {
    for (int i = 0; i < n / 3; i++) {
      cout << "1 ";
      if (cnt[2] > 0) {
        cout << "2 ";
        cnt[2]--;
        if (cnt[4] > 0) {
          cout << "4\n";
          cnt[4]--;
        } else if (cnt[6] > 0) {
          cout << "6\n";
          cnt[6]--;
        }
      } else if (cnt[3] > 0) {
        cout << "3 ";
        cnt[3]--;
        if (cnt[6] > 0) {
          cout << "6\n";
          cnt[6]--;
        }
      }
    }
  } else
    cout << "-1"
         << "\n";
  return 0;
}
