#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
struct matrix {
  vector<long long int> a, b, c;
};
void solve() {
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  long long int i, j, k;
  i = 0;
  j = n / 3;
  k = j + (n / 3);
  matrix ans;
  long long int x = 89;
  while (k < n) {
    if (arr[i] != arr[j] && arr[j] % arr[i] == 0) {
      if (arr[j] != arr[k] && arr[k] % arr[j] == 0) {
        ans.a.push_back(arr[i]);
        ans.b.push_back(arr[j]);
        ans.c.push_back(arr[k]);
        i++;
        j++;
        k++;
      } else {
        x = 23;
        break;
      }
    } else {
      x = 23;
      break;
    }
  }
  if (x == 23) {
    cout << -1;
  } else {
    long long int i = 0;
    while (i < n / 3) {
      cout << ans.a[i] << " " << ans.b[i] << " " << ans.c[i] << "\n";
      i++;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  { solve(); }
}
