#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int M = 300005;
const int mod = 1e9 + 9;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
using namespace std;
int t, n;
int cnt[11];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int first;
    scanf("%d", &first);
    cnt[first]++;
  }
  if ((cnt[1] * 3 != n) || cnt[5] || cnt[7]) return puts("-1"), 0;
  if (cnt[2] < cnt[4]) return puts("-1"), 0;
  if (cnt[2] + cnt[3] != cnt[4] + cnt[6]) return puts("-1"), 0;
  while (cnt[4]) cout << 1 << " " << 2 << " " << 4 << endl, cnt[4]--, cnt[2]--;
  while (cnt[2]) cout << 1 << " " << 2 << " " << 6 << endl, cnt[2]--;
  while (cnt[3]) cout << 1 << " " << 3 << " " << 6 << endl, cnt[3]--;
  return 0;
}
