#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  bool cnt = 0;
  long long n, one = 0, two = 0, three = 0, four = 0, six = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (x == 1)
      one++;
    else if (x == 2)
      two++;
    else if (x == 3)
      three++;
    else if (x == 4)
      four++;
    else if (x == 6)
      six++;
    else if (x == 5 || x == 7)
      cnt = 1;
  }
  if (cnt || (three > six) ||
      !((one == two + three) && (two + three == four + six))) {
    cout << -1 << "\n";
    return 0;
  }
  while (three--) {
    cout << "1 3 6"
         << "\n";
    six--;
  }
  while (six--) {
    cout << "1 2 6"
         << "\n";
    two--;
  }
  while (two--) {
    cout << "1 2 4"
         << "\n";
  }
  return 0;
}
