#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mp[arr[i]]++;
  }
  if ((int)(mp.size()) < 3) {
    printf("-1\n");
  } else {
    bool sw = 0;
    for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
      if (it->second > (n / 3)) {
        sw = 1;
        break;
      }
    }
    if (sw)
      printf("-1\n");
    else {
      vector<vector<int> > hadi;
      vector<int> tmp;
      for (int i = 0; i < n / 3; i++) {
        tmp.clear();
        int cnt = 0, last = -1;
        for (map<int, int>::iterator it = mp.begin(); it != mp.end() && cnt < 3;
             it++) {
          if (it->second != 0) {
            if (last == -1) {
              cnt++;
              tmp.push_back(it->first);
              mp[it->first]--;
              last = it->first;
            } else if (((int)(it->first / last)) * last == it->first) {
              cnt++;
              tmp.push_back(it->first);
              mp[it->first]--;
              last = it->first;
            }
          }
        }
        if ((int)(tmp.size()) < 3) {
          printf("-1\n");
          return 0;
        }
        hadi.push_back(tmp);
      }
      sort((hadi).begin(), (hadi).end());
      for (int i = 0; i < (int)(hadi.size()); i++) {
        cout << hadi[i][0] << ' ' << hadi[i][1] << ' ' << hadi[i][2] << endl;
      }
    }
  }
  return 0;
}
