#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[100000];
  int freq[8];
  for (int i = 0; i <= 7; i++) freq[i] = 0;
  bool failed = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 5 || arr[i] == 7) {
      failed = 1;
      break;
    }
    freq[arr[i]]++;
  }
  if (failed)
    cout << -1 << endl;
  else if (freq[1] != (n / 3))
    cout << -1 << endl;
  else if (freq[2] + freq[3] != (n / 3))
    cout << -1 << endl;
  else if (freq[6] < freq[3])
    cout << -1 << endl;
  else if (freq[6] + freq[4] != (n / 3))
    cout << -1 << endl;
  else {
    for (int i = 0; i < n / 3; i++) {
      cout << 1 << " ";
      if (freq[2] > 0) {
        cout << 2 << " ";
        freq[2]--;
      } else {
        cout << 3 << " ";
        freq[3]--;
      }
      if (freq[4] > 0) {
        cout << 4 << " ";
        freq[4]--;
      } else {
        cout << 6 << " ";
        freq[6]--;
      }
      cout << endl;
    }
  }
  return 0;
}
