#include <bits/stdc++.h>
using namespace std;
int n, num[100005], f, l, r, a, b, c, ans[100005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    if (num[i] == 1) c++;
  }
  if (c != n / 3) {
    cout << -1;
    return 0;
  }
  sort(num, num + n);
  for (int i = 0; i < n / 3; i++) {
    ans[r] = 1;
    if (num[(n / 3) + i] == 2 || num[(n / 3) + i] == 3) {
      ans[r + 1] = num[(n / 3) + i];
      if (ans[r + 1] == 3) {
        if (num[2 * (n / 3) + i] == 6) {
          ans[r + 2] = num[2 * (n / 3) + i];
        } else {
          cout << -1;
          return 0;
        }
      }
      if (ans[r + 1] == 2) {
        if (num[2 * (n / 3) + i] == 6 || num[2 * (n / 3) + i] == 4) {
          ans[r + 2] = num[2 * (n / 3) + i];
        } else {
          cout << -1;
          return 0;
        }
      }
    } else {
      cout << -1;
      return 0;
    }
    r += 3;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
    if ((i + 1) % 3 == 0) cout << endl;
  }
}
