#include <bits/stdc++.h>
using namespace std;
mt19937 rang(chrono::steady_clock::now().time_since_epoch().count());
long long mult(long long x, long long y);
long long add(long long x, long long y);
long long powmod(long long base, long long expo);
long long mod(long long n, long long m);
const long long MOD = 1e9 + 7;
const long long N = 3e5;
void solve() {
  long long n, k, i, j;
  cin >> n;
  vector<long long> v(n);
  for (i = 0; i < n; ++i) cin >> v[i];
  ;
  map<long long, long long> m;
  for (i = 0; i < n; ++i) {
    ++m[v[i]];
  }
  if (m[5] > 0 or m[7] > 0) {
    cout << -1 << " ";
    cout << "\n";
    ;
    return;
  }
  vector<vector<long long> > ans;
  long long type1 = 0, type2 = 0, type3 = 0;
  type1 = min(m[1], min(m[2], m[4]));
  m[1] -= type1, m[2] -= type1, m[4] -= type1;
  type2 = min(m[1], min(m[2], m[6]));
  m[1] -= type2, m[2] -= type2, m[6] -= type2;
  type3 = min(m[1], min(m[3], m[6]));
  m[1] -= type3, m[3] -= type3, m[6] -= type3;
  for (i = 1; i <= 7; ++i) {
    if (m[i] > 0) {
      cout << -1 << " ";
      cout << "\n";
      ;
      return;
    }
  }
  for (i = 0; i < type1; ++i) {
    vector<long long> x{1, 2, 4};
    ans.push_back(x);
  }
  for (i = 0; i < type2; ++i) {
    vector<long long> x{1, 2, 6};
    ans.push_back(x);
  }
  for (i = 0; i < type3; ++i) {
    vector<long long> x{1, 3, 6};
    ans.push_back(x);
  }
  for (i = 0; i < n / 3; ++i) {
    for (j = 0; j < 3; ++j) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  };
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
inline long long mult(long long x, long long y) {
  x %= MOD;
  y %= MOD;
  return (1LL * x * y) % MOD;
}
inline long long add(long long x, long long y) {
  x += y;
  return x % MOD;
}
inline long long powmod(long long base, long long expo) {
  if (base == 0) return 0;
  long long ans = 1;
  while (expo) {
    if (expo & 1) ans = mult(ans, base);
    base = mult(base, base);
    expo >>= 1;
  }
  return ans;
}
inline long long mod(long long n, long long m = MOD) {
  n %= m, n += m, n %= m;
  return n;
}
inline long long rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
