#include <bits/stdc++.h>
using namespace std;
long long int cnt[7];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, a, x;
  bool test = true;
  vector<pair<long long int, pair<long long int, long long int>>> v;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    cnt[a]++;
  }
  x = n / 3;
  if (cnt[1] + cnt[2] + cnt[3] + cnt[4] + cnt[6] != n) test = false;
  if (cnt[1] == x && test) {
    for (i = 1; i <= x; i++) {
      if (cnt[4] > 0) {
        if (cnt[2] > 0) {
          v.push_back({1, {2, 4}});
          cnt[2]--;
          cnt[4]--;
        } else {
          test = false;
          break;
        }
      } else if (cnt[3] > 0) {
        if (cnt[6] > 0) {
          v.push_back({1, {3, 6}});
          cnt[3]--;
          cnt[6]--;
        } else {
          test = false;
          break;
        }
      } else if (cnt[2] > 0) {
        if (cnt[6] > 0) {
          v.push_back({1, {2, 6}});
          cnt[2]--;
          cnt[6]--;
        } else {
          test = false;
          break;
        }
      }
    }
  } else
    test = false;
  if (test && cnt[2] == 0 && cnt[6] == 0 && cnt[3] == 0 && cnt[4] == 0) {
    for (i = 0; i < v.size(); i++)
      cout << v[i].first << " " << v[i].second.first << " "
           << v[i].second.second << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
