#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int MAX = 200005;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int arr[8]{0}, n, item{0};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> item;
    arr[item]++;
  }
  if (arr[5] > 0 || arr[7] > 0) {
    cout << -1;
    return 0;
  }
  int p = n / 3;
  vector<tuple<int, int, int> > v;
  while (p--) {
    if (arr[1] > 0 && arr[2] > 0 && arr[4] > 0) {
      v.push_back(make_tuple(1, 2, 4));
      arr[1]--;
      arr[2]--;
      arr[4]--;
    } else if (arr[1] > 0 && arr[2] > 0 && arr[6] > 0) {
      v.push_back(make_tuple(1, 2, 6));
      arr[1]--;
      arr[2]--;
      arr[6]--;
    } else if (arr[1] > 0 && arr[3] > 0 && arr[6] > 0) {
      v.push_back(make_tuple(1, 3, 6));
      arr[1]--;
      arr[3]--;
      arr[6]--;
    } else {
      cout << "-1";
      return 0;
    }
  }
  for (int i = 0; i < v.size(); i++)
    cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << "\n";
  return 0;
}
