#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n, m, c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  int cnt[8] = {0};
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  if (cnt[7] || cnt[5]) {
    cout << "-1";
    return 0;
  }
  int req = n / 3;
  for (int i = 1; i < 8; i++) {
    if (cnt[i] > req) {
      cout << "-1";
      return 0;
    }
  }
  for (int i = 0; i < req; i++) {
    if (cnt[1] && cnt[2] && cnt[4]) {
      c1++;
      cnt[1]--;
      cnt[2]--;
      cnt[4]--;
    } else if (cnt[1] && cnt[2] && cnt[6]) {
      c2++;
      cnt[1]--;
      cnt[2]--;
      cnt[6]--;
    } else if (cnt[1] && cnt[3] && cnt[6]) {
      c3++;
      cnt[1]--;
      cnt[3]--;
      cnt[6]--;
    }
  }
  if (c1 + c2 + c3 != req) {
    cout << -1;
  } else {
    for (int i = 0; i < c1; i++) {
      cout << "1 2 4\n";
    }
    for (int i = 0; i < c2; i++) {
      cout << "1 2 6\n";
    }
    for (int i = 0; i < c3; i++) {
      cout << "1 3 6\n";
    }
  }
  return 0;
}
