#include <bits/stdc++.h>
using namespace std;
template <typename T>
void inputArray(T arr[], int n) {
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
}
int min(int &a, int &b, int &c) {
  if (a < b && a < c) return a;
  if (b < a && b < c) return b;
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n{0};
  cin >> n;
  int arr[8] = {0}, temp{0};
  bool isOk{true};
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> temp;
    arr[temp]++;
    if (temp == 7 || temp == 5) {
      isOk = false;
    }
  }
  std::vector<std::vector<int>> v;
  if (isOk) {
    for (int(i) = (1); (i) < (4); (i)++) {
      if (arr[i]) {
        if (i * 3 < 8 || arr[i * 3]) {
          if (i * 3 * 2 < 8 || arr[i * 3 * 2]) {
            int m = min(arr[i], arr[i * 3], arr[i * 3 * 2]);
            arr[i] -= m;
            arr[i * 3] -= m;
            arr[i * 3 * 2] -= m;
            std::vector<int> proxy = {i, i * 3, i * 3 * 2, m};
            v.push_back(proxy);
          }
        }
        if ((i * 2 < 8 || arr[i * 2]) && arr[i]) {
          if (i * 3 * 2 < 8 || arr[i * 3 * 2]) {
            int m = min(arr[i], arr[i * 2], arr[i * 3 * 2]);
            arr[i] -= m;
            arr[i * 2] -= m;
            arr[i * 3 * 2] -= m;
            std::vector<int> proxy = {i, i * 2, i * 3 * 2, m};
            v.push_back(proxy);
          }
          if ((i * 2 * 2 < 8 || arr[i * 2 * 2]) && arr[i]) {
            int m = min(arr[i], arr[i * 2], arr[i * 2 * 2]);
            arr[i] -= m;
            arr[i * 2] -= m;
            arr[i * 2 * 2] -= m;
            std::vector<int> proxy = {i, i * 2, i * 2 * 2, m};
            v.push_back(proxy);
          }
        }
      }
    }
  }
  for (int(i) = (1); (i) < (8); (i)++) {
    if (arr[i]) {
      isOk = false;
      break;
    }
  }
  if (isOk) {
    for (auto(i) : (v)) {
      for (int(j) = (0); (j) < (i[3]); (j)++) {
        cout << i[0] << " " << i[1] << " " << i[2] << endl;
      }
    }
  } else {
    cout << "-1" << endl;
  }
  return 0;
}
