#include <bits/stdc++.h>   using namespace std;   vector<long long int> prime;   unordered_set<long long int> stprime;   void sieve(long long int n) {     bool p[n + 1];     memset(p, true, sizeof(p));     for (long long int i = 2; i * i <= n; i++) {       if (p[i]) {         for (int j = i * i; j <= n; j += i) {           p[j] = false;         }       }     }     for (long long int i = 2; i <= n; i++) {       if (p[i]) {         prime.push_back(i);         stprime.insert(i);       }     }   }   void solve() {     long long int m;     cin >> m;     long long int arr[8];     memset(arr, 0, sizeof(arr));     for (int i = 0; i < m; i++) {       long long int a;       cin >> a;       arr[a]++;     }     m /= 3;     if (arr[1] != m || arr[5] | arr[7] || arr[2] < arr[4] || arr[6] < arr[3] ||         arr[2] + arr[3] != arr[4] + arr[6]) {       cout <<  -1  << endl;     } else {       for (int i = 1; i <= arr[4]; i++) cout <<  1 2 4  << endl;       for (int i = 1; i <= arr[2] - arr[4]; i++) cout <<  1 2 6  << endl;       for (int i = 1; i <= arr[3]; i++) cout <<  1 3 6  << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     t = 1;     while (t--) {       solve();     }     return 0;   }   