#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
void solve() {
  int n;
  cin >> n;
  int arr[8]{0};
  bool possible = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == 5 || a == 7) {
      possible = false;
    }
    arr[a]++;
  }
  vector<int> ans;
  while (ans.size() < n && possible) {
    bool found = false;
    for (int i = 1; i < 5 && !found && possible; i++) {
      if (arr[i] > 0) {
        for (int j = i + 1; j < 7 && !found && possible; j++) {
          if (arr[j] > 0 && j % i == 0) {
            for (int k = j + 1; k < 7 && !found; k++) {
              if (arr[k] > 0 && k % j == 0) {
                ans.push_back(i);
                ans.push_back(j);
                ans.push_back(k);
                found = true;
                arr[i]--;
                arr[j]--;
                arr[k]--;
                break;
              }
            }
            if (!found) {
              possible = false;
            }
          }
        }
        if (!found) {
          possible = false;
        }
      }
    }
  }
  if (possible) {
    for (int i = 0; i < ans.size(); i += 3) {
      cout << ans[i] << " " << ans[i + 1] << " " << ans[i + 2] << "\n";
    }
  } else {
    cout << -1 << "\n";
  }
}
