#include <bits/stdc++.h>
using namespace std;
constexpr char newline = '\n';
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, temp;
  cin >> n;
  vector<int> v(8);
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    v[temp]++;
  }
  if (v[1] == n / 3 && (v[2] + v[3]) == n / 3 && (v[4] + v[6]) == n / 3) {
    if (v[2]) {
      if (((v[2] - v[4]) >= 0) && ((v[2] - v[4]) == (v[6] - v[3]))) {
        for (int i = 0; i < n / 3; ++i)
          cout << "1 " << ((v[2]-- > 0) ? 2 : 3) << " "
               << ((v[4]-- > 0) ? 4 : 6) << "\n";
      } else
        cout << "-1";
    } else if (v[3] > 0 && v[3] == v[6]) {
      while (v[3]--) cout << "1 3 6\n";
    } else
      cout << "-1";
  } else
    cout << "-1";
  return 0;
}
