#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[100000000 + 1] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


/*
______
$     $  !       !  @@@@@        $
$_____$  !       !  @   @       @ @
$*       !       !  @@@@@      @   @
$ **     !       !  @         *******
$  ***   !       !  @        @       @
$   **** !_______!  @      *@         @*
*/
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
//#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
int32_t main()
{
	c_p_c();
	int n, m; cin >> n >> m;
	std::vector<int> v;
	int a[m] = {0};
	int b[n];
	int sum = 0;
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++)a[b[i]] = b[i];
	for (int i = 1; i <= m; i++)
	{
		if (a[i] != i && sum < m)
		{
			v.push_back(i);
			sum = sum + i;
		}
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[100000000] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[1000000000] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007

#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[100000000] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[100000] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[100000000] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = false;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pair              pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r+", stdin);
	freopen("oup.txt", "w+", stdout);
#endif
}
main()
{	c_p_c();
	int n, m;
	cin >> n >> m;
	std::vector<int> v;
	bool a[1000000001] = {false};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int i = 1;
	int sum = 0;
	while (sum < m)
	{
		if (a[i] == false)
		{
			v.push_back(i);
			sum = sum + i;
		}
		i++;
	}
	if (sum > m)v.pop_back();
	cout << v.size() << "\n";
	for (auto i : v)cout << i << " ";

}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st, len, sum;

  cin >> n >> m;

  vector<int> ans, a;

  a.push_back(0);
  for(int i = 0; i < n; i++)
  {
     int x;
     cin >> x;
     a.push_back(x);
  }
  a.push_back(1e9 + 1);

  cur = m;
  sort(a.begin(), a.end());

  for(int i = 0; i < a.size() - 1; i++)
  {
     l = a[i] + 1;
     r = a[i + 1] - 1;

     if(l > r) continue;
     if(cur < l) break;

     st = l;
     len = r - l + 1;
     l = 1;
     r = len;

     while(l < r)
     {
        midn = (l + r) / 2;
        sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }

     for(int j = st; j <= st + l - 1; j++)
     {
        ans.push_back(j);
        cur -= j;
     }
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st;
  cin >> n >> m;

  int a[n];
  vector<int> ans;

  for(int i = 0; i < n; i++)
    cin >> a[i];

  cur = m;
  sort(a, a + n);

  l = 1;

  for(int i = 0; i < n; i++)
  {
     r = a[i] - 1;
     if(l > r)
     {
       l = a[i] + 1;
       continue;
     }

     if(cur < l)
       break;

     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }

     for(int j = st; j <= r; j++)
     {
        ans.push_back(j);
        cur -= j;
     }

     l = a[i + 1];
  }

  if(cur >= l)
  {
     r = 1e9;
     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }
     for(int j = st; j <= r; j++)
       ans.push_back(j);
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st;
  cin >> n >> m;

  int a[n];
  vector<int> ans;

  for(int i = 0; i < n; i++)
    cin >> a[i];

  cur = m;
  sort(a, a + n);

  l = 1;

  for(int i = 0; i < n; i++)
  {
     r = a[i] - 1;
     if(l > r)
     {
       l = a[i] + 1;
       continue;
     }

     if(cur < l)
       break;

     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * l + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }
     for(int j = st; j <= l; j++)
     {
        ans.push_back(j);
        cur -= j;
     }
     l = a[i + 1];
  }

  if(cur >= l)
  {
     r = 1e9;
     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * l + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }
     for(int j = st; j <= l; j++)
       ans.push_back(j);
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st;
  cin >> n >> m;

  int a[n];
  vector<int> ans;

  for(int i = 0; i < n; i++)
    cin >> a[i];

  cur = m;
  sort(a, a + n);

  l = 1;

  for(int i = 0; i < n; i++)
  {
     r = a[i] - 1;
     if(l > r)
     {
       l = a[i] + 1;
       continue;
     }

     if(cur < l)
       break;

     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }

     for(int j = st; j <= l; j++)
     {
        ans.push_back(j);
        cur -= j;
     }

     l = a[i + 1] + 1;
  }

  if(cur >= l)
  {
     r = 1e9;
     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }
     for(int j = st; j <= l; j++)
       ans.push_back(j);
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st;
  cin >> n >> m;

  int a[n];
  vector<int> ans;

  for(int i = 0; i < n; i++)
    cin >> a[i];

  cur = m;
  sort(a, a + n);

  l = 1;

  for(int i = 0; i < n; i++)
  {
     r = a[i] - 1;
     if(l > r)
     {
       l = a[i] + 1;
       continue;
     }

     if(cur < l)
       break;

     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }

     for(int j = st; j <= r; j++)
     {
        ans.push_back(j);
        cur -= j;
     }

     l = a[i + 1] + 1;
  }

  if(cur >= l)
  {
     r = 1e9;
     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }
     for(int j = st; j <= r; j++)
       ans.push_back(j);
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st, len, sum;

  cin >> n >> m;

  vector<int> ans, a;

  a.push_back(0);
  for(int i = 0; i < n; i++)
  {
     int x;
     cin >> x;
     a.push_back(x);
  }
  a.push_back(1e9 + 1);

  cur = m;
  sort(a.begin(), a.end());

  for(int i = 0; i < a.size() - 1; i++)
  {
     l = a[i] + 1;
     r = a[i + 1] - 1;

     if(l > r) continue;
     if(cur < l) break;

     st = l;
     len = r - l + 1;
     l = 1;
     r = len;

     while(l < r)
     {
        midn = (l + r) / 2;
        sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else if(sum == cur)
        {
          l = midn;
          break;
        }
        else
           r = midn;
     }

     for(int j = st; j <= st + l - 1; j++)
     {
        ans.push_back(j);
        cur -= j;
     }
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st, len, sum;

  cin >> n >> m;

  vector<int> ans, a;

  a.push_back(0);
  for(int i = 0; i < n; i++)
  {
     int x;
     cin >> x;
     a.push_back(x);
  }
  a.push_back(1e9 + 1);

  cur = m;
  sort(a.begin(), a.end());

  for(int i = 0; i < a.size() - 1; i++)
  {
     l = a[i] + 1;
     r = a[i + 1] - 1;

     if(l > r) continue;
     if(cur < l) break;

     st = l;
     len = r - l + 1;
     l = 1;
     r = len;

     while(l < r)
     {
        midn = (l + r) / 2;
        sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }

     if(l * (2 * st + l - 1) > 2 * cur) --l;

     for(int j = st; j <= st + l - 1; j++)
     {
        ans.push_back(j);
        cur -= j;
     }
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include<bits/stdc++.h>
 using namespace std;

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int n, m, l, r, midn, cur, st;
  cin >> n >> m;

  int a[n];
  vector<int> ans;

  for(int i = 0; i < n; i++)
    cin >> a[i];

  cur = m;
  sort(a, a + n);

  l = 1;

  for(int i = 0; i < n; i++)
  {
     r = a[i] - 1;
     if(l > r)
     {
       l = a[i] + 1;
       continue;
     }

     if(cur < l)
       break;

     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }

     for(int j = st; j <= l; j++)
     {
        ans.push_back(j);
        cur -= j;
     }

     l = a[i + 1];
  }

  if(cur >= l)
  {
     r = 1e9;
     st = l;

     while(l < r)
     {
        midn = (l + r) / 2;
        int sum = midn * (2 * st + midn - 1);

        if(sum < 2 * cur)
           l = midn + 1;
        else
           r = midn;
     }
     for(int j = st; j <= l; j++)
       ans.push_back(j);
  }

  cout << ans.size() << endl;
  for(int i : ans)
    cout << i << ' ';

  return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int v[1000001];
int a[1000001];

int main()
{
    long long n,m,i,x=1;
    long long c=0;
    cin>>n;
    cin>>m;
    for(i=1; i<=n; i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1; i<=n+1; i++)
    {
        if(m>=x)
        {
            if(x!=v[i])
            {

                m-=x;
                i--;

                x++;
                c++;
a[c]=x-1;
            }
            else x++;
        }
        else
        {
            cout<<c<<'\n';
            break;
        }

    }
    for(i=1;i<=c;i++){
    cout<<a[i]<<" ";}

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
string s;

int main()
{
    int k,i,x,c,lungime,j,aux;
    c=0;

    long long n;
    n=0;
    cin>>k;
    cin>>s;
    lungime=s.length();
    for(i=0; i<lungime; i++)
    {
        n+=s[i]-'0';
        if(n>=k)
        {
            cout<<c;
            c=1;
            break;
        }
    }

    if(c==0)
    {
        /*
        for(i=0; i<=lungime-2; i++)
        {
            for(j=i+1; j<=lungime-1; j++)
            {
                if(s[i]<s[j])
                {
                    aux=s[i];
                    s[i]=s[j];
                    s[j]=aux;
                }
            }
        }
        */
        sort(&s[0], &s[lungime]);
        x=k-n;
        for(i=0; i<lungime; i++)
        {
            if( x>9)
            {
                x -= s[lungime -i] - '0';
                c++;
            }
            else if(x>0)
            {
                if(x+s[lungime-i] - '0' < 9)
                {
                    c++;
                    x=0;
                }
                else
                {
                    x -= s[lungime-i] - '0';
                    c++;
                }
            }
            else
            {
                cout<<c;
                break;
            }

            {

            }
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int v[1000000001];

int main()
{
    long long n,m,i,x=1;
    long long c=0;
    cin>>n;
    cin>>m;
    for(i=1; i<=n; i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1; i<=n+1; i++)
    {
        if(m>=x)
        {
            if(x!=v[i])
            {

                m-=x;
                i--;
                x++;
                c++;
            }
            else x++;
        }
        else
        {
            cout<<c;
            break;
        }

    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int v[1000000001];

int main()
{
    int n,m,i,x=1;
    int c=0;
    cin>>n;
    cin>>m;
    for(i=1; i<=n; i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1; i<=n+1; i++)
    {
        if(m>=x)
        {
            if(x!=v[i])
            {

                m-=x;
                i--;
                x++;
                c++;
            }
            else x++;
        }
        else
        {
            cout<<c;
            break;
        }

    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int v[1000001];

int main()
{
    long long n,m,i,x=1;
    long long c=0;
    cin>>n;
    cin>>m;
    for(i=1; i<=n; i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1; i<=n+1; i++)
    {
        if(m>=x)
        {
            if(x!=v[i])
            {

                m-=x;
                i--;
                x++;
                c++;
            }
            else x++;
        }
        else
        {
            cout<<c;
            break;
        }

    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    map<int,bool> a;
    vector<int> t;

    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int an;
        cin>>an;
        a[an]=true;
    }

    for(int i=1; i<=m ; i++)
    {
        if(a[i]==false && m-i >= 0 )
        {
            t.push_back(i);
            m-=i;
        }
        if(m<=0) break;
    }
    cout<<t.size()<<endl;
    for(int i=0; i<t.size(); i++)
    {
        cout<<t[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int S = 1e9+5;
bitset<S> a;
int main()
{
    int n,m;
    vector<int> t;

    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int an;
        cin>>an;
        a[an]=true;
    }
    int cnt = 0;
    for(int i=1; i<=m; i++)
    {
        if(cnt>=m)
            break;
        else if(a[i]==false && cnt+i<=m)
        {
            cnt += i;
            t.push_back(i);
        }
    }

    cout<<t.size()<<endl;
    for(int i=0;i<t.size();i++){
        cout<<t[i]<<" ";
    }

    return 0;
}


/*
Alyona and Toys
https://codeforces.com/problemset/problem/659/C
*/
#include <bits/stdc++.h>
using namespace std;
bool a[1000000000+4];
int main()
{
    int n,m;
    vector<int> t;

    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int an;
        cin>>an;
        a[an]=true;
    }
    int cnt = 0;
    for(int i=1; i<=m; i++)
    {
        if(cnt>=m)
            break;
        else if(a[i]==false && cnt+i<=m)
        {
            cnt += i;
            t.push_back(i);
        }
    }

    cout<<t.size()<<endl;
    for(int i=0;i<t.size();i++){
        cout<<t[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    map<int,bool> a;
    vector<int> t;

    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int an;
        cin>>an;
        a[an]=true;
    }
    int cnt = 0;
    for(int i=1; i<=m; i++)
    {
        if(cnt>=m)
            break;
        else if(a[i]==false && cnt+i<=m)
        {
            cnt += i;
            t.push_back(i);
        }
    }

    cout<<t.size()<<endl;
    for(int i=0;i<t.size();i++){
        cout<<t[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int S = 1e9+5;
bool a[S];
int main()
{
    int n,m;
    vector<int> t;

    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int an;
        cin>>an;
        a[an]=true;
    }
    int cnt = 0;
    for(int i=1; i<=m; i++)
    {
        if(cnt>=m)
            break;
        else if(a[i]==false && cnt+i<=m)
        {
            cnt += i;
            t.push_back(i);
        }
    }

    cout<<t.size()<<endl;
    for(int i=0;i<t.size();i++){
        cout<<t[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int size = 1e9+5;
bool a[size];
int main()
{
    int n,m;
    vector<int> t;

    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int an;
        cin>>an;
        a[an]=true;
    }
    int cnt = 0;
    for(int i=1; i<=m; i++)
    {
        if(cnt>=m)
            break;
        else if(a[i]==false && cnt+i<=m)
        {
            cnt += i;
            t.push_back(i);
        }
    }

    cout<<t.size()<<endl;
    for(int i=0;i<t.size();i++){
        cout<<t[i]<<" ";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl  '\n'
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REP1(i1,n)  for(ll i=1;i<n;i++)
#define pb push_back
#define mk make_pair
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll b[10000];
    vector<ll>v;
    ll N=1e9;
    memset(b,0,sizeof(b));
    REP(i,n)
    {
        cin>>a[i];
        b[a[i]-1]=1;
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {

        if(b[i]!=1)
        {
            v.pb(i+1);
            ans+=i+1;
        }
         if(ans>m)break;
    }
    ll len=v.size();
    if(ans>m)len--;
    cout<<len<<endl;
    for(ll i=0;i<len;i++)cout<<v[i]<<" ";

}

/*

Alhamdulilla...

*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl  '\n'
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REP1(i1,n)  for(ll i=1;i<n;i++)
#define pb push_back
#define mk make_pair
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll b[100000];
    vector<ll>v;
    ll N=1e9;
    memset(b,0,sizeof(b));
    REP(i,n)
    {
        cin>>a[i];
        b[a[i]-1]=1;
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {

        if(b[i]!=1)
        {
            v.pb(i+1);
            ans+=i+1;
        }
         if(ans>m)break;
    }
    ll len=v.size();
    if(ans>m)len--;
    cout<<len<<endl;
    for(ll i=0;i<len;i++)cout<<v[i]<<" ";

}

/*

Alhamdulilla...

*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl  '\n'
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REP1(i1,n)  for(ll i=1;i<n;i++)
#define pb push_back
#define mk make_pair
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    vector<ll>v;
    ll N=1e9;
    map<ll,ll>mp;
    REP(i,n)
    {
        cin>>a[i];
        mp[a[i]-1]=1;
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {

        if(mp[i]!=1)
        {
            v.pb(i+1);
            ans+=i+1;
        }
         if(ans>m)break;
    }
    ll len=v.size();
    if(ans>m)len--;
    cout<<len<<endl;
    for(ll i=0;i<len;i++)cout<<v[i]<<" ";

}

/*

Alhamdulilla...

*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl  '\n'
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REP1(i1,n)  for(ll i=1;i<n;i++)
#define pb push_back
#define mk make_pair
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll b[100005];
    vector<ll>v;
    ll N=1e9;
    memset(b,0,sizeof(b));
    REP(i,n)
    {
        cin>>a[i];
        b[a[i]-1]=1;
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {

        if(b[i]!=1)
        {
            v.pb(i+1);
            ans+=i+1;
        }
         if(ans>m)break;
    }
    ll len=v.size();
    if(ans>m)len--;
    cout<<len<<endl;
    for(ll i=0;i<len;i++)cout<<v[i]<<" ";

}

/*

Alhamdulilla...

*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl  '\n'
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REP1(i1,n)  for(ll i=1;i<n;i++)
#define pb push_back
#define mk make_pair
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    vector<ll>v;
    ll N=1e9;
    ll b[100050];
    memset(b,0,sizeof(b));
    REP(i,n)
    {
        cin>>a[i];
        b[a[i]-1]=1;
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {

        if(b[i]!=1)
        {
            v.pb(i+1);
            ans+=i+1;
        }
         if(ans>m)break;
    }
    ll len=v.size();
    if(ans>m)len--;
    cout<<len<<endl;
    for(ll i=0;i<len;i++)cout<<v[i]<<" ";

}

/*

Alhamdulilla...

*/


#include <bits/stdc++.h>

using namespace std;

int main()
{
     int x,y;
    cin>>x>>y;
    int a[x],sum=0,i1=0,i2=1,b[x];
    for(int i=0;i<x;i++) cin>>a[i];
        sort(a,a+x);
        while (y-i2>=0){
            if(a[i1]!=i2){
                b[sum]=i2;
                sum++;
                y-=i2;
            }
            else i1++;
            i2++;
        }
    cout<<sum<<endl;
    for(int i=0;i<sum;i++) cout<<b[i]<<" ";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int x,y;

    cin>>x>>y;
    long long int a[x],sum=0,i1=0,i2=1,b[x];
    for(long long int i=0;i<x;i++)
        cin>>a[i];
        sort(a,a+x);
        for(long long int i=0;i<x;i++){
        while (i2<a[i]&&y>0){b[sum]=i2; i2++;  sum++; y-=i2;  if(y<1) break;}
        i2++;
        }
        while (y>0){ b[sum]=i2;  sum++; y-=i2; i2++; }

    cout<<sum<<endl;
    for(int i=0;i<sum;i++) cout<<b[i]<<" ";

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
 main(){
     int x,y;
    cin>>x>>y;
    int a[x],b[100001],sum=0,i1=0,i2=1,i=0,i4=0;
    while(i<x) {cin>>a[i]; i++;}
        sort(a,a+x);
        while (y-i2>=0){
            if(a[i1]!=i2){
                b[sum]=i2;
                sum++;
                y-=i2;
            }
            else i1++;
            i2++;
        }
    cout<<sum<<endl;
    while (i4<sum) {cout<<b[i4]<<" "; i4++;}

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int x,y;

    cin>>x>>y;
    long long int a[x],sum=0,i1=0,i2=1,b[x];
    for(int i=0;i<x;i++)
        cin>>a[i];
        sort(a,a+x);
        for(int i=0;i<x;i++){
        while (i2<a[i]&&y>0){b[sum]=i2; i2++;  sum++; y-=i2; cout<<"y= "<<y<<" sum= "<<sum<<" b[sum]= "<<b[sum-1]<<endl; if(y<1) break;}
        i2++;
        }
        while (y>0){ b[sum]=i2;  sum++; y-=i2; i2++; cout<<"y= "<<y<<" sum= "<<sum<<" b[sum]=**** "<<b[sum-1]<<endl; }

    cout<<sum<<endl;
    for(int i=0;i<sum;i++) cout<<b[i]<<" ";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int x,y;

    cin>>x>>y;
    long long int a[x],sum=0,i1=0,i2=1,b[x];
    for(long long int i=0;i<x;i++)
        cin>>a[i];
        sort(a,a+x);
        while (y-i2>=0){
            if(a[i1]!=i2){
                b[sum]=i2;
                sum++;
                y-=i2;

            }
            else i1++;
            i2++;
        }

    cout<<sum<<endl;
    for(int i=0;i<sum;i++) cout<<b[i]<<" ";

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
 main(){
     int x,y;
    cin>>x>>y;
    int a[x],b[x],sum=0,i1=0,i2=1,i=0,i4=0;
    while(i<x) {cin>>a[i]; i++;}
        sort(a,a+x);
        while (y-i2>=0){
            if(a[i1]!=i2){
                b[sum]=i2;
                sum++;
                y-=i2;
            }
            else i1++;
            i2++;
        }
    cout<<sum<<endl;
    while (i4<sum) {cout<<b[i4]<<" "; i4++;}

}


#include <bits/stdc++.h>
using namespace std;
// __builtin_popcount

int n, m, x, i = 1, ans = 0;
map<int, int> res;
vector<int> an;

int main() {
	cin >> n >> m;
	while (n--) {
		cin >> x;
		res[x] = 1;
	}
	while (m-i>=0) {
		if (!res[i])
			ans++, an.push_back(i), m -= i;
		i++;
	}
	cout << ans << endl;
	for (auto m : an)
		cout << m << " ";
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
// __builtin_popcount

int n, m, x, i = 1, ans = 0;
map<int, int> res;
vector<int> an;

int main() {
    ios_base::sync_with_stdio(false);
cin.tie(NULL);
	cin >> n >> m;
	while (n--) {
		cin >> x;
		res[x] = 1;
	}
	while (m-i>=0) {
		if (!res[i])
			ans++, an.push_back(i), m -= i;
		i++;
	}
	cout << ans << endl;
	for (auto m : an)
		cout << m << " ";
	cout << endl;
}


#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<stack>
#include<numeric>
#include<iterator>
#define ll long long int
#define pb push_back
using namespace std;

int main()
{
	int n;
	int money;
	map<int, int> m1;
	vector<int> ans;
	int i = 1;
	int counter=0;
	cin >> n >> money;
	for (int j = 0; j < n; j++)
	{
		int a; cin >> a; m1[a]++;
	}
	while (money - i >= 0)
	{
		if (!m1[i])
		{
			counter++;
			ans.push_back(i);
			money -= i;
		}
		i++;
	}
	cout << counter<<endl;
	for (auto x : ans)
		cout << x << " ";
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
// __builtin_popcount

int n, m, x, i = 1, ans = 0;
map<int, int> res;
vector<int> an;

int main() {ios_base::sync_with_stdio(false);
cin.tie(NULL);
	cin >> n >> m;
	while (n--) {
		cin >> x;
		res[x] = 1;
	}
	while (m-i>=0) {
		if (!res[i])
			ans++, an.push_back(i), m -= i;
		i++;
	}
	cout << ans << endl;
	for (auto m : an)
		cout << m << " ";
	cout << endl;
}


#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<stack>
#include<numeric>
#include<iterator>
#define ll long long int
#define pb push_back
using namespace std;

int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
	int n;
	int money;
	map<int, int> m1;
	vector<int> ans;
	int i = 1;
	int counter=0;
	cin >> n >> money;
	for (int j = 0; j < n; j++)
	{
		int a; cin >> a; m1[a]++;
	}
	while (money - i >= 0)
	{
		if (!m1[i])
		{
			counter++;
			ans.push_back(i);
			money -= i;
		}
		i++;
	}
	cout << counter<<endl;
	for (auto x : ans)
		cout << x << " ";
	cout << endl;
}


#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<stack>
#include<numeric>
#include<iterator>
#define ll long long int
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
	int n;
	int money;
	map<int, int> m1;
	vector<int> ans;
	int i = 1;
	int counter=0;
	cin >> n >> money;
	for (int j = 0; j < n; j++)
	{
		int a; cin >> a; m1[a]++;
	}
	while (money - i >= 0)
	{
		if (!m1[i])
		{
			counter++;
			ans.push_back(i);
			money -= i;
		}
		i++;
	}
	cout << counter<<endl;
	for (auto x : ans)
		cout << x << " ";
	cout << endl;
}


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define end        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))
ll int ara[10000000];
using namespace std;
int main()
{
      faster;
      ll int n,m,a,b,c,d,e,p,q,r,s,t,x,y,z,i,j=0,k,count=0;
      ll int str[100000]={};
            cin>>n>>m;
            for(i=0;i<n;i++){
                  cin>>a;
                  ara[a]++;
            }
            b=m;
            for(i=1;i<=b;i++){
                 if(ara[i]==0){
                       if(m-i>=0){
                              m-=i;
                              count++;
                              str[j]=i;
                              j++;
                       }
                       else break;
                 }
            }
            cout<<count<<endl;
            for(i=0;i<j;i++){
                  cout<<str[i]<<" ";
            }
      return 0;
}


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define end        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))
ll int ara[99999999];
using namespace std;
int main()
{
      faster;
      ll int n,m,a,b,c,d,e,p,q,r,s,t,x,y,z,i,j=0,k,count=0;
      ll int str[100000]={};
            cin>>n>>m;
            for(i=0;i<n;i++){
                  cin>>a;
                  ara[a]++;
            }
            b=m;
            for(i=1;i<=b;i++){
                 if(ara[i]==0){
                       if(m-i>=0){
                              m-=i;
                              count++;
                              str[j]=i;
                              j++;
                       }
                       else break;
                 }
            }
            cout<<count<<endl;
            for(i=0;i<j;i++){
                  cout<<str[i]<<" ";
            }
      return 0;
}


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define end        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))

using namespace std;
int main()
{
      faster;
      ll int n,m,a,b,c,d,e,p,q,r,s,t,x,y,z,i,j=0,k,count=0;
      ll int ara[100000]={};
      ll int str[100000]={};
            cin>>n>>m;
            for(i=0;i<n;i++){
                  cin>>a;
                  ara[a]++;
            }
            b=m;
            for(i=1;i<=b;i++){
                 if(ara[i]==0){
                       if(m-i>=0){
                              m-=i;
                              count++;
                              str[j]=i;
                              j++;
                       }
                       else break;
                 }
            }
            cout<<count<<endl;
            for(i=0;i<j;i++){
                  cout<<str[i]<<" ";
            }
      return 0;
}


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define end        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))
using namespace std;
int main()
{
      faster;
      ll int n,m,a,b,c,d,e,p,q,r,s,t,x,y,z,i,j,k,count=0;
      ll int str[100000]={};
            cin>>n>>m;
            ll int ara[n];
            for(i=0;i<n;i++){
                  cin>>ara[i];
            }
            k=0,j=0;
            b=m;
            sort(ara,ara+n);
            for(i=1;i<=b;i++){
                        if(i==ara[j]){
                              if(j<n-1)j++;
                        }
                        else{
                              if(m-i>=0){
                                    count++;
                                    m-=i;
                                    str[k]=i;
                                    k++;
                              }
                              else break;
                        }
            }
            cout<<count<<endl;
            for(i=0;i<k;i++){
                  cout<<str[i]<<" ";
            }

      return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 7;
int a[N];
int main()
{
    int n, k, ci, ans1 = 0;
    cin >> n >> k;
    int ans2[k];
    for (int i = 1; i <= n; i++)
    {
        cin >> ci;
        a[ci] = 1;
    }
    for (int i = 1; k - i >= 0; i++)
    {
        if (a[i] != 1)
        {
            ans2[ans1++] = i;
            k -= i;
        }
    }
    cout << ans1 << "\n";
    for (int i = 0; i < ans1; i++)
        cout << ans2[i] << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 7;
int a[N] = {};
vector<int>v;
int main()
{
    long long n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        long long ci;
        cin >> ci;
        a[ci] = 1;
    }
    long long cnt = 1;
    while (k - cnt >= 0)
    {
        if (a[cnt] != 1)
        {
            v.push_back(cnt);
            k -= cnt;
        }
        cnt++;
    }
    cout << v.size() << "\n";
    for (int i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 7;
int a[N];
vector<int>v;
int main()
{
    long long n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        long long ci;
        cin >> ci;
        a[ci] = 1;
    }
    for (int i = 1; k - i >= 0; i++)
    {
        if (a[i] != 1)
        {
            v.push_back(i);
            k -= i;
        }
    }
    cout << v.size() << "\n";
    for (int i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    return 0;
}


#include<iostream>
#include<sstream>
#include<vector>
#include <stdio.h>
#include <ctype.h>
#include<set>
#include<math.h>
#include<algorithm>
#include <stdio.h>      /* printf */
#include <stdlib.h>
#include<string>
#include<stack>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
bool comp(ll n)
{
	for(int i=2;i<n;i++){if(n%i==0)return true;}
	return false;

}
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

string toBinary(int n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main()
{
	ll n,x;
	while(cin>>n)
	{
		ll num[8];
		bool z=true;;
		vector<ll >ans;
		for(int i=0;i<8;i++)num[i]=0;
		for(int i=0;i<n;i++){cin>>x;num[x]++;}
		for(int i=0;i<n/3;i++)
		{
			//if((num[3]==0&&num[2]==0)||num[1]==0){cout<<"-1"<<endl;break;}
			if(num[7]>0){cout<<"-1"<<endl;break;}
			if(num[1]&&num[2]&&num[4]){ans.push_back(1);ans.push_back(2);ans.push_back(4); num[1]--;num[2]--;num[4]--;}
			else if(num[1]&&num[2]&&num[6]){ans.push_back(1);ans.push_back(2);ans.push_back(6); num[1]--;num[2]--;num[6]--;}
			else if(num[1]&&num[3]&&num[6]){ans.push_back(1);ans.push_back(3);ans.push_back(6); num[1]--;num[3]--;num[6]--;}
			else {cout<<"-1"<<endl;z=false;break;}

		}
		if(z)
		{
			for(int i=0;i<n;i+=3)cout<<ans[i]<<" "<<ans[i+1]<<" "<<ans[i+2]<<endl;

		}

	}
	return 0;
}


#include<iostream>
#include<sstream>
#include<vector>
#include <stdio.h>
#include <ctype.h>
#include<set>
#include<math.h>
#include<algorithm>
#include <stdio.h>      /* printf */
#include <stdlib.h>
#include<string>
#include<stack>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
bool comp(ll n)
{
	for(int i=2;i<n;i++){if(n%i==0)return true;}
	return false;

}
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

string toBinary(int n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main()
{
	ll n,x;
	while(cin>>n)
	{
		ll num[8];
		bool z=true;;
		vector<ll >ans;
		ans.push_back(0);
		for(int i=0;i<8;i++)num[i]=0;
		for(int i=0;i<n;i++){cin>>x;num[x]++;}
		for(int i=0;i<n/3;i++)
		{
			//if((num[3]==0&&num[2]==0)||num[1]==0){cout<<"-1"<<endl;break;}
			if(num[7]>0){cout<<"-1"<<endl;break;}
			if(num[1]&&num[2]&&num[4]){ans.push_back(1);ans.push_back(2);ans.push_back(4); num[1]--;num[2]--;num[4]--;}
			else if(num[1]&&num[2]&&num[6]){ans.push_back(1);ans.push_back(2);ans.push_back(6); num[1]--;num[2]--;num[6]--;}
			else if(num[1]&&num[3]&&num[6]){ans.push_back(1);ans.push_back(3);ans.push_back(6); num[1]--;num[3]--;num[6]--;}
			else {cout<<"-1"<<endl;z=false;break;}

		}
		if(z)
		{
			for(int i=1;i<=n;i+=3)cout<<ans[i]<<" "<<ans[i+1]<<" "<<ans[i+2]<<endl;

		}

	}
	return 0;
}


#include<iostream>
#include<sstream>
#include<vector>
#include <stdio.h>
#include <ctype.h>
#include<set>
#include<math.h>
#include<algorithm>
#include <stdio.h>      /* printf */
#include <stdlib.h>
#include<string>
#include<stack>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
bool comp(ll n)
{
	for(int i=2;i<n;i++){if(n%i==0)return true;}
	return false;

}
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

string toBinary(int n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main()
{
	ll n,x;
	while(cin>>n)
	{
		ll num[8];
		bool z=true;;
		vector<ll >ans;
		ans.push_back(0);
		for(int i=0;i<8;i++)num[i]=0;
		for(int i=0;i<n;i++){cin>>x;num[x]++;}
		for(int i=0;i<n/3;i++)
		{
			//if((num[3]==0&&num[2]==0)||num[1]==0){cout<<"-1"<<endl;break;}
			if(num[7]>0){cout<<"-1"<<endl;z=false;break;}
			if(num[1]&&num[2]&&num[4]){ans.push_back(1);ans.push_back(2);ans.push_back(4); num[1]--;num[2]--;num[4]--;}
			else if(num[1]&&num[2]&&num[6]){ans.push_back(1);ans.push_back(2);ans.push_back(6); num[1]--;num[2]--;num[6]--;}
			else if(num[1]&&num[3]&&num[6]){ans.push_back(1);ans.push_back(3);ans.push_back(6); num[1]--;num[3]--;num[6]--;}
			else {cout<<"-1"<<endl;z=false;break;}

		}
		if(z)
		{
			for(int i=1;i<=n;i+=3)cout<<ans[i]<<" "<<ans[i+1]<<" "<<ans[i+2]<<endl;

			ans.clear();
		}

	}
	return 0;
}


#include<iostream>
#include<sstream>
#include<vector>
#include <stdio.h>
#include <ctype.h>
#include<set>
#include<math.h>
#include<algorithm>
#include <stdio.h>      /* printf */
#include <stdlib.h>
#include<string>
#include<stack>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
bool comp(ll n)
{
	for(int i=2;i<n;i++){if(n%i==0)return true;}
	return false;

}
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

string toBinary(int n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main()
{
	ll n,x;
	while(cin>>n)
	{
		ll num[8];
		bool z=true;;
		vector<ll >ans;
		ans.push_back(0);
		for(int i=0;i<8;i++)num[i]=0;
		for(int i=0;i<n;i++){cin>>x;num[x]++;}
		for(int i=0;i<n/3;i++)
		{
			//if((num[3]==0&&num[2]==0)||num[1]==0){cout<<"-1"<<endl;break;}
			if(num[7]>0){cout<<"-1"<<endl;z=false;break;}
			if(num[1]&&num[2]&&num[4]){ans.push_back(1);ans.push_back(2);ans.push_back(4); num[1]--;num[2]--;num[4]--;}
			else if(num[1]&&num[2]&&num[6]){ans.push_back(1);ans.push_back(2);ans.push_back(6); num[1]--;num[2]--;num[6]--;}
			else if(num[1]&&num[3]&&num[6]){ans.push_back(1);ans.push_back(3);ans.push_back(6); num[1]--;num[3]--;num[6]--;}
			else {cout<<"-1"<<endl;z=false;break;}

		}
		if(z)
		{
			for(int i=1;i<=ans.size();i+=3)cout<<ans[i]<<" "<<ans[i+1]<<" "<<ans[i+2]<<endl;

			ans.clear();
		}

	}
	return 0;
}


#include<iostream>
#include<sstream>
#include<vector>
#include <stdio.h>
#include <ctype.h>
#include<set>
#include<math.h>
#include<algorithm>
#include <stdio.h>      /* printf */
#include <stdlib.h>
#include<string>
#include<stack>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
bool comp(ll n)
{
	for(int i=2;i<n;i++){if(n%i==0)return true;}
	return false;

}
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

string toBinary(int n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main()
{
	ll n,x;
	while(cin>>n)
	{
		ll num[8];
		for(int i=0;i<8;i++)num[i]=0;
		for(int i=0;i<n;i++){cin>>x;num[x]++;}
		for(int i=0;i<n/3;i++)
		{
			//if((num[3]==0&&num[2]==0)||num[1]==0){cout<<"-1"<<endl;break;}
		//	if(num[7]>0){cout<<"-1"<<endl;break;}
			if(num[1]&&num[2]&&num[4]){cout<<1<<" "<<2<<" "<<4<<endl; num[1]--;num[2]--;num[4]--;}
			else if(num[1]&&num[2]&&num[6]){cout<<1<<" "<<2<<" "<<6<<endl; num[1]--;num[2]--;num[6]--;}
			else if(num[1]&&num[3]&&num[6]){cout<<1<<" "<<3<<" "<<6<<endl; num[1]--;num[3]--;num[6]--;}
			else {cout<<"-1"<<endl;break;}

		}

	}
	return 0;
}


/*
 * a3535454.cpp
 *
 *  Created on: Aug 25, 2020
 *      Author: mk-elbaz
 */

/*
 ───────────▄▄▄▄▄▄▄▄▄▄▄▄▄
 ────────▄▀▀─────────────▀▀▄
 ───────█───────────────────█
 ──────█─────────────────────█
 ─────█───▄▄▄▄▄▄▄───▄▄▄▄▄▄▄───█
 ────█───█████████─█████████───█
 ────█──██▀────▀█████▀────▀██──█
 ───██████───█▀█─███───█▀█─██████
 ───██████───▀▀▀─███───▀▀▀─██████
 ────█──▀█▄────▄██─██▄────▄█▀──█
 ────█────▀█████▀───▀█████▀────█
 ────█───────────────▄▄▄───────█
 ────█───────▄▄▄▄██▀▀█▀▀█▄─────█
 ────█─────▄██▄█▄▄█▄▄█▄▄██▄────█
 ────█─────▀▀█████████████▀────█
 ───▐▓▓▌─────────────────────▐▓▓▌
 ───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
 ───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
 ──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
 ──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█

 ──█───█─█──█─█▀▀█─▀▀█▀▀─▀█─█─▀█──
 ──█▄█▄█─█▀▀█─█▄▄█───█───█▀─▀─█▀──
 ───▀─▀──▀──▀─▀──▀───▀───▄──▄─▄───
 BAZ

 */

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <cmath>
#include <string>
#include <iterator>
#include <map>

using namespace std;

void printVector(vector<int> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << ' ';
    }
}

void printVector(vector<pair<int, int>> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].first << ' ' << v[i].second << endl;
    }
}

void printArray (int s[], int n){
    for (int i = 0; i<n; i++) {
        cout << s[i] << ' ';
    }
}

int sumArray (int a[],int b, int e){
    int sum = 0;
    for (int i = b; i < e; i++) {
        //   cout << a[i] << ' ' ;
        sum += a[i];
    }
    // cout << "sum: " << sum <<  endl;
    return sum;
}

int elementCount (int nums[] , int n, int a){
    int counter = 0;
    for (int i = 0; i < n ; i++) {
        if (nums[i] == a) {
            counter++;
        }
    }
    return counter;
}

int countDistinct(int a[], int size){
    int i, j, count = 1;
    for (i = 1; i < size; i++){
        for (j = 0; j < i; j++){
            if (a[i] == a[j]){
                break;
            }
        }
        if (i == j){
            count++;
        }
    }
    return count;
}
//at most 7
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }
    sort(a , a+n );
    int ones = elementCount(a, n , 1);
    int twos = elementCount(a, n , 2);
    int threes = elementCount(a, n , 3);
    int fours = elementCount(a, n , 4);
    int six = elementCount(a, n , 6);
    bool flag = false;
    if (ones + twos + threes + six + fours != n) {
        cout << "-1" << endl;
    }else{
        while (ones > 0 && twos > 0 && fours > 0) {
            flag = true;
            cout << "1 2 4" << endl;
            ones--;
            twos--;
            fours--;
        }
        while (ones > 0 && twos > 0 && six > 0) {
            flag = true;
            cout << "1 2 6" << endl;
            ones--;
            twos--;
            six--;
        }
        while (ones > 0 && threes > 0 && six > 0) {
            flag = true;
            cout << "1 3 6" << endl;
            ones--;
            threes--;
            six--;
        }
        if (!flag) {
            cout << -1 << endl;
        }
    }
}


/*
 * a3535454.cpp
 *
 *  Created on: Aug 25, 2020
 *      Author: mk-elbaz
 */

/*
 ───────────▄▄▄▄▄▄▄▄▄▄▄▄▄
 ────────▄▀▀─────────────▀▀▄
 ───────█───────────────────█
 ──────█─────────────────────█
 ─────█───▄▄▄▄▄▄▄───▄▄▄▄▄▄▄───█
 ────█───█████████─█████████───█
 ────█──██▀────▀█████▀────▀██──█
 ───██████───█▀█─███───█▀█─██████
 ───██████───▀▀▀─███───▀▀▀─██████
 ────█──▀█▄────▄██─██▄────▄█▀──█
 ────█────▀█████▀───▀█████▀────█
 ────█───────────────▄▄▄───────█
 ────█───────▄▄▄▄██▀▀█▀▀█▄─────█
 ────█─────▄██▄█▄▄█▄▄█▄▄██▄────█
 ────█─────▀▀█████████████▀────█
 ───▐▓▓▌─────────────────────▐▓▓▌
 ───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
 ───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
 ──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
 ──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█

 ──█───█─█──█─█▀▀█─▀▀█▀▀─▀█─█─▀█──
 ──█▄█▄█─█▀▀█─█▄▄█───█───█▀─▀─█▀──
 ───▀─▀──▀──▀─▀──▀───▀───▄──▄─▄───
 BAZ

 */

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <cmath>
#include <string>
#include <iterator>
#include <map>

using namespace std;

void printVector(vector<int> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << ' ';
    }
}

void printVector(vector<pair<int, int>> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].first << ' ' << v[i].second << endl;
    }
}

void printArray (int s[], int n){
    for (int i = 0; i<n; i++) {
        cout << s[i] << ' ';
    }
}

int sumArray (int a[],int b, int e){
    int sum = 0;
    for (int i = b; i < e; i++) {
        //   cout << a[i] << ' ' ;
        sum += a[i];
    }
    // cout << "sum: " << sum <<  endl;
    return sum;
}

int elementCount (int nums[] , int n, int a){
    int counter = 0;
    for (int i = 0; i < n ; i++) {
        if (nums[i] == a) {
            counter++;
        }
    }
    return counter;
}

int countDistinct(int a[], int size){
    int i, j, count = 1;
    for (i = 1; i < size; i++){
        for (j = 0; j < i; j++){
            if (a[i] == a[j]){
                break;
            }
        }
        if (i == j){
            count++;
        }
    }
    return count;
}
//at most 7
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }
    sort(a , a+n );
    int ones = elementCount(a, n , 1);
    int twos = elementCount(a, n , 2);
    int threes = elementCount(a, n , 3);
    int fours = elementCount(a, n , 4);
    int six = elementCount(a, n , 6);
    bool flag = false;
    while (ones > 0 && twos > 0 && fours > 0) {
        flag = true;
        cout << "1 2 4" << endl;
        ones--;
        twos--;
        fours--;
    }
    while (ones > 0 && twos > 0 && six > 0) {
        flag = true;
        cout << "1 2 6" << endl;
        ones--;
        twos--;
        six--;
    }
    while (ones > 0 && threes > 0 && six > 0) {
        flag = true;
        cout << "1 3 6" << endl;
        ones--;
        threes--;
        six--;
    }
    if (!flag) {
        cout << -1 << endl;
    }
}


/*
 * a3535454.cpp
 *
 *  Created on: Aug 25, 2020
 *      Author: mk-elbaz
 */

/*
 ───────────▄▄▄▄▄▄▄▄▄▄▄▄▄
 ────────▄▀▀─────────────▀▀▄
 ───────█───────────────────█
 ──────█─────────────────────█
 ─────█───▄▄▄▄▄▄▄───▄▄▄▄▄▄▄───█
 ────█───█████████─█████████───█
 ────█──██▀────▀█████▀────▀██──█
 ───██████───█▀█─███───█▀█─██████
 ───██████───▀▀▀─███───▀▀▀─██████
 ────█──▀█▄────▄██─██▄────▄█▀──█
 ────█────▀█████▀───▀█████▀────█
 ────█───────────────▄▄▄───────█
 ────█───────▄▄▄▄██▀▀█▀▀█▄─────█
 ────█─────▄██▄█▄▄█▄▄█▄▄██▄────█
 ────█─────▀▀█████████████▀────█
 ───▐▓▓▌─────────────────────▐▓▓▌
 ───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
 ───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
 ──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
 ──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█

 ──█───█─█──█─█▀▀█─▀▀█▀▀─▀█─█─▀█──
 ──█▄█▄█─█▀▀█─█▄▄█───█───█▀─▀─█▀──
 ───▀─▀──▀──▀─▀──▀───▀───▄──▄─▄───
 BAZ

 */

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <cmath>
#include <string>
#include <iterator>
#include <map>

using namespace std;

void printVector(vector<int> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << ' ';
    }
}

void printVector(vector<pair<int, int>> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].first << ' ' << v[i].second << endl;
    }
}

void printArray (int s[], int n){
    for (int i = 0; i<n; i++) {
        cout << s[i] << ' ';
    }
}

int sumArray (int a[],int b, int e){
    int sum = 0;
    for (int i = b; i < e; i++) {
        //   cout << a[i] << ' ' ;
        sum += a[i];
    }
    // cout << "sum: " << sum <<  endl;
    return sum;
}

int elementCount (int nums[] , int n, int a){
    int counter = 0;
    for (int i = 0; i < n ; i++) {
        if (nums[i] == a) {
            counter++;
        }
    }
    return counter;
}

int countDistinct(int a[], int size){
    int i, j, count = 1;
    for (i = 1; i < size; i++){
        for (j = 0; j < i; j++){
            if (a[i] == a[j]){
                break;
            }
        }
        if (i == j){
            count++;
        }
    }
    return count;
}
//at most 7
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }
    sort(a , a+n );
    int ones = elementCount(a, n , 1);
    int twos = elementCount(a, n , 2);
    int threes = elementCount(a, n , 3);
    int fours = elementCount(a, n , 4);
    int six = elementCount(a, n , 6);
    bool flag = false;
    if (ones + twos + threes + six + fours != n) {
        cout << "-1" << endl;
        return 0;
    }
    if(threes > six || threes > ones){
        cout << "-1" << endl;
        return 0;
    }
    six -= threes;
    ones -= threes;
    if(six + fours != twos || twos != ones ){
        cout << "-1" << endl;
    }else{
        while (fours--) {
            flag = true;
            cout << "1 2 4" << endl;
        }
        while (six--) {
            flag = true;
            cout << "1 2 6" << endl;
        }
        while (threes--) {
            flag = true;
            cout << "1 3 6" << endl;
        }
        if (!flag) {
            cout << -1 << endl;
        }
    }
}


/*
 * a3535454.cpp
 *
 *  Created on: Aug 25, 2020
 *      Author: mk-elbaz
 */

/*
 ───────────▄▄▄▄▄▄▄▄▄▄▄▄▄
 ────────▄▀▀─────────────▀▀▄
 ───────█───────────────────█
 ──────█─────────────────────█
 ─────█───▄▄▄▄▄▄▄───▄▄▄▄▄▄▄───█
 ────█───█████████─█████████───█
 ────█──██▀────▀█████▀────▀██──█
 ───██████───█▀█─███───█▀█─██████
 ───██████───▀▀▀─███───▀▀▀─██████
 ────█──▀█▄────▄██─██▄────▄█▀──█
 ────█────▀█████▀───▀█████▀────█
 ────█───────────────▄▄▄───────█
 ────█───────▄▄▄▄██▀▀█▀▀█▄─────█
 ────█─────▄██▄█▄▄█▄▄█▄▄██▄────█
 ────█─────▀▀█████████████▀────█
 ───▐▓▓▌─────────────────────▐▓▓▌
 ───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
 ───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
 ──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
 ──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
 ──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█

 ──█───█─█──█─█▀▀█─▀▀█▀▀─▀█─█─▀█──
 ──█▄█▄█─█▀▀█─█▄▄█───█───█▀─▀─█▀──
 ───▀─▀──▀──▀─▀──▀───▀───▄──▄─▄───
 BAZ

 */

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <cmath>
#include <string>
#include <iterator>
#include <map>

using namespace std;

void printVector(vector<int> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << ' ';
    }
}

void printVector(vector<pair<int, int>> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].first << ' ' << v[i].second << endl;
    }
}

void printArray (int s[], int n){
    for (int i = 0; i<n; i++) {
        cout << s[i] << ' ';
    }
}

int sumArray (int a[],int b, int e){
    int sum = 0;
    for (int i = b; i < e; i++) {
        //   cout << a[i] << ' ' ;
        sum += a[i];
    }
    // cout << "sum: " << sum <<  endl;
    return sum;
}

int elementCount (int nums[] , int n, int a){
    int counter = 0;
    for (int i = 0; i < n ; i++) {
        if (nums[i] == a) {
            counter++;
        }
    }
    return counter;
}

int countDistinct(int a[], int size){
    int i, j, count = 1;
    for (i = 1; i < size; i++){
        for (j = 0; j < i; j++){
            if (a[i] == a[j]){
                break;
            }
        }
        if (i == j){
            count++;
        }
    }
    return count;
}
//at most 7
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }
    sort(a , a+n );
    int ones = elementCount(a, n , 1);
    int twos = elementCount(a, n , 2);
    int threes = elementCount(a, n , 3);
    int fours = elementCount(a, n , 4);
    int six = elementCount(a, n , 6);
    bool flag = false;
    if (ones + twos + threes + six + fours != n) {
        cout << "-1" << endl;
    }else if(threes > six || threes > ones){
        cout << "-1" << endl;
    }else if(six + fours != twos || twos != ones ){
        cout << "-1" << endl;
    }else{
        while (ones > 0 && twos > 0 && fours > 0) {
            flag = true;
            cout << "1 2 4" << endl;
            ones--;
            twos--;
            fours--;
        }
        while (ones > 0 && twos > 0 && six > 0) {
            flag = true;
            cout << "1 2 6" << endl;
            ones--;
            twos--;
            six--;
        }
        while (ones > 0 && threes > 0 && six > 0) {
            flag = true;
            cout << "1 3 6" << endl;
            ones--;
            threes--;
            six--;
        }
        if (!flag) {
            cout << -1 << endl;
        }
    }
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    long n,one=0,two=0,three=0,four=0,six=0;
    cin>>n;
    int x[n];
    for(long i=0;i<n;i++){
        cin>>x[i];
        switch(x[i]){
            case 1:
                one++;
                break;
            case 2:
                two++;
                break;
            case 3:
                three++;
                break;
            case 4:
                four++;
                break;
            case 6:
                six++;
                break;
        }
    }
    if(one == 0){
        cout<<"-1"<<endl;
    }
    else if(one == two + three && one == four + six && one == n/3){
        if(two == 0){
            if(three == six){
                for(int i=1;i<=six;i++){
                    cout<<"1 "<<"3 " <<"6"<<endl;
                }
            }
            else{
                cout<<"-1"<<endl;
            }
        }
        else if(three == 0){
            if(two == four + six){
                for(int i=1;i<=four;i++){
                    cout<<"1 "<<"2 " <<"4"<<endl;
                }
                for(int i=1;i<=two-four;i++){
                    cout<<"1 "<<"2 " <<"6"<<endl;
                }
            }
            else{
                cout<<"-1"<<endl;
            }
        }
        else if(two + three == four + six && six != 0 && six-(abs(two-four)) == three){
                for(int i=1;i<=four;i++){
                    cout<<"1 "<<"2 " <<"4"<<endl;
                }
                for(int i=1;i<=two-four;i++){
                    cout<<"1 "<<"2 " <<"6"<<endl;
                }
                for(int i=1;i<=three;i++){
                    cout<<"1 "<<"3 " <<"6"<<endl;
                }
        }
        else{
            cout<<"-1"<<endl;
        }
    }
    else{
        cout<<"-1"<<endl;
    }
}


#include <iostream>

using namespace std;

int main()
{
    long n,one=0,two=0,three=0,four=0,six=0;
    cin>>n;
    int x[n];
    for(long i=0;i<n;i++){
        cin>>x[i];
        switch(x[i]){
            case 1:
                one++;
                break;
            case 2:
                two++;
                break;
            case 3:
                three++;
                break;
            case 4:
                four++;
                break;
            case 6:
                six++;
                break;
        }
    }
    if(one == 0){
        cout<<"-1"<<endl;
    }
    else if(one == two + three && one == four + six && one == n/3){
        if(two == 0){
            if(three == six){
                for(int i=1;i<=six;i++){
                    cout<<"1 "<<"3 " <<"6"<<endl;
                }
            }
            else{
                cout<<"-1"<<endl;
            }
        }
        else if(three == 0){
            if(two == four + six){
                for(int i=1;i<=four;i++){
                    cout<<"1 "<<"2 " <<"4"<<endl;
                }
                for(int i=1;i<=two-four;i++){
                    cout<<"1 "<<"2 " <<"6"<<endl;
                }
            }
            else{
                cout<<"-1"<<endl;
            }
        }
        else if(two + three == four + six && six != 0 && six-(two-four) == three){
                for(int i=1;i<=four;i++){
                    cout<<"1 "<<"2 " <<"4"<<endl;
                }
                for(int i=1;i<=two-four;i++){
                    cout<<"1 "<<"2 " <<"6"<<endl;
                }
                for(int i=1;i<=three;i++){
                    cout<<"1 "<<"3 " <<"6"<<endl;
                }
        }
        else{
            cout<<"-1"<<endl;
        }
    }
    else{
        cout<<"-1"<<endl;
    }
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int x;
    cin>>x;
    int z[x],y[x/3][3]={0},b;
    bool False=true;
    for(int i=0;i<x;i++)
    {
        cin>>z[i];
    }
    sort(z,z+x);

    for(int i=0;i<x/3;i++)
    {
        y[i][0]=z[i];
        z[i]=0;
    }
    for(int i=0;i<x/3;i++)
    {
        b=0;
        while(true)
        {
            int j;
            for(j=0;j<x;j++)
            {
                if(z[j]%y[i][b]==0 && z[j]!=y[i][b] && z[j]!=0)
                {
                    b++;
                    y[i][b]=z[j];
                    z[j]=0;
                    break;
                }
            }
           if(b==2)
                break;
            else if(j==x)
            {
                False=false;
                break;            }
        }
    }
    if(False)
    {
       for(int i=0;i<x/3;i++)
   {
        for(int j=0;j<3;j++)
        {
            cout<<y[i][j]<<" ";
       }
       cout<<endl;
    }
    }
    else
    {
        cout<<"-1"<<endl;
    }

}


#include <iostream>

using namespace std;

int main()
{
    int x;
    cin>>x;
    int z[x],y[x/3][3]={0},b;
    bool False=true;
    for(int i=0;i<x;i++)
    {
        cin>>z[i];
    }
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<x;j++)
        {
            if(z[i]<z[j])
                swap(z[i],z[j]);
        }
    }
    for(int i=0;i<x/3;i++)
    {
        y[i][0]=z[i];
        z[i]=0;
    }
    for(int i=0;i<x/3;i++)
    {
        b=0;
        while(true)
        {
            int j;
            for(j=0;j<x;j++)
            {
                if(z[j]%y[i][b]==0 && z[j]!=y[i][b] && z[j]!=0)
                {
                    b++;
                    y[i][b]=z[j];
                    z[j]=0;
                    break;
                }
            }
            if(b==2)
                break;
            else if(j==x)
            {
                False=false;
                break;
            }
        }
    }
    if(False)
    {
        for(int i=0;i<x/3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cout<<y[i][j]<<" ";
        }
        cout<<endl;
    }
    }
    else
    {
        cout<<"-1"<<endl;
    }

}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector <int> a; //Раньше делал с повторяющимися элементами
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        if(find(a.begin(),a.end(),temp)==a.end())
            a.push_back(temp);
    }
    sort(a.begin(),a.end());
    bool check=true;
    for(int i=0;i<a.size();i++){
        for(int j=i+1;j<a.size();j++){
            if(a[j]>a[i]&&a[j]%a[i]==0){
                for(int k=j+1;k<a.size();k++){
                    if(a[k]>a[j]&&a[k]%a[j]==0){
                        cout<<a[i]<<" "<<a[j]<<" "<<a[k];
                        check=false;
                        if(i!=n-1||j!=n-1||k!=n-1)
                            cout<<"\n";
                    }
                }
            }
        }
    }
    if(check)
        cout<<-1;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    /*for(int i=0;i<n;i++)
        cout<<a[i];
    cout<<"\n";*/
    bool null=true;
    for(int i=0;i<=n/3;i++){
        bool check=false;
        for(int j=0;j<n;j++){
                if(a[j]!=-1)
            for(int k=j+1;k<n;k++){
                if(a[j]!=a[k] && a[k]!=-1)
                for(int l=k+1;l<n;l++){
                    if(a[l]!=-1&&a[j]<a[k]&&a[k]<a[l]&&a[k]%a[j]==0&&a[l]%a[k]==0){
                        if(!null)
                            cout<<"\n";
                        cout<<a[j]<<" "<<a[k]<<" "<<a[l];
                        a[j]=-1; a[k]=-1; a[l]=-1;
                        check=true;
                        null=false;
                        break;
                    }
                }
                if(check)
                    break;
            }
            if(check)
                break;
        }
    }
    if(null)
        cout<<-1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	map<int,int> numeros;
	vector<int> saida;
	int quant;
	cin >> quant;
	for(int i = 0; i < quant; i++){
		int num;
		cin >> num;
		numeros[num]++;
	}
	for(int i = 0; i < quant/3; i++){
		bool p = true, s = false, t = false;
		for(auto r: numeros){
			if(r.second == 0) continue;
			if(p){
				saida.push_back(r.first);
				s = true;
				p = false;
				r.second--;
			}
			else if(s && r.first > saida[saida.size() - 1] && r.first % saida[saida.size() -1] == 0){
				saida.push_back(r.first);
				t = true;
				s = false;
				r.second--;
			}
			else if(t && r.first > saida[saida.size() - 1] && r.first % saida[saida.size() -1] == 0){
				saida.push_back(r.first);
				t = false;
				r.second--;
			}
		}
	}
	int n = 0;
	if(saida.size() == quant){
		for(int i = 0; i < quant /3; i++){
			for(int j = 0; j < 3; j++){
				cout << saida[n++] << " \n"[j == 2];
			}
		}
	}else{
		printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	map<int,int> numeros;
	vector<int> saida;
	int quant;
	cin >> quant;
	for(int i = 0; i < quant; i++){
		int num;
		cin >> num;
		numeros[num]++;
	}
	for(int i = 0; i < quant/3; i++){
		bool p = true, s = false, t = false;
		for(auto r: numeros){
			if(p){
				saida.push_back(r.first);
				s = true;
				p = false;
				r.second--;
			}
			else if(s && r.first > saida[saida.size() - 1] && r.first % saida[saida.size() -1] == 0){
				saida.push_back(r.first);
				t = true;
				s = false;
				r.second--;
			}
			else if(t && r.first > saida[saida.size() - 1] && r.first % saida[saida.size() -1] == 0){
				saida.push_back(r.first);
				t = false;
				r.second--;
			}
			if(r.second == 0) numeros.erase(r.first);
		}
	}
	int n = 0;
	if(saida.size() == quant){
		for(int i = 0; i < quant /3; i++){
			for(int j = 0; j < 3; j++){
				cout << saida[n++] << " \n"[j == 2];
			}
		}
	}else{
		printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<vector<int> > saidas;
int usados[100000];

int main(){
    int n;
    vector<int> valores;
    cin >> n;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        valores.push_back(num);
    }
    sort(valores.begin(),valores.end());
    for(int i = 0; i < n; i++){
        if(usados[i]) continue;
        vector<int> aux;
        int con = i;
        usados[con] = 1;
        aux.push_back(valores[con++]);

        for(; con < n; con++){
            if(aux.back() < valores[con] && !usados[con] && (valores[con] % aux.back()) == 0){
                usados[con] = 1;
                aux.push_back(valores[con++]);
                break;
            }
        }
        for(; con < n; con++){
            if(aux.back() < valores[con] && !usados[con] && (valores[con] % aux.back()) == 0){
                usados[con] = 1;
                aux.push_back(valores[con++]);
                break;
            }
        }
        if(aux.size() == 3)
            saidas.push_back(aux);
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    for(auto r: saidas){
        printf("%d %d %d\n",r[0],r[1],r[2]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<vector<int> > saidas;
int val[8];

int main(){
    int n;

    cin >> n;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        val[num]++;
    }
    while(val[1] > 0 && val[2] > 0 && val[4] > 0){
        val[1]--; val[2]--; val[4]--;
        saidas.push_back({1,2,4});
    }
    while(val[1] > 0 && val[2] > 0 && val[6] > 0){
        val[1]--; val[2]--; val[6]--;
        saidas.push_back({1,2,6});
    }
    while(val[1] > 0 && val[3] > 0 && val[6] > 0){
        val[1]--; val[3]--; val[6]--;
        saidas.push_back({1,3,6});
    }
    if(saidas.size() == (n/3)){
        for(auto r: saidas)
            printf("%d %d %d\n",r[0],r[1],r[2]);
    }else{
        cout << -1 << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<vector<int> > saidas;
int usados[100000];

int main(){
    int n;
    vector<int> valores;
    cin >> n;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        valores.push_back(num);
    }
    sort(valores.begin(),valores.end());
    for(int i = 0; i < (n/3); i++){
        if(usados[i]) continue;
        vector<int> aux;
        int con = i;
        usados[con] = 1;
        aux.push_back(valores[con++]);

        for(; con < n; con++){
            if(aux.back() < valores[con] && !usados[con] && (valores[con] % aux.back()) == 0){
                usados[con] = 1;
                aux.push_back(valores[con++]);
                break;
            }
        }
        for(; con < n; con++){
            if(aux.back() < valores[con] && !usados[con] && (valores[con] % aux.back()) == 0){
                usados[con] = 1;
                aux.push_back(valores[con++]);
                break;
            }
        }
        if(aux.size() == 3)
            saidas.push_back(aux);
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    for(auto r: saidas){
        printf("%d %d %d\n",r[0],r[1],r[2]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	vector<int> ent;
	vector<int> sai;
	int usa[99999];
	int quant;
	cin >> quant;
	memset(usa,0,sizeof(int)*99999);
	for(int i = 0; i < quant; i++){
		int num;
		cin >> num;
		ent.push_back(num);
	}
	sort(ent.begin(),ent.end());
	for(int i = 0; i < quant/3; i++){
		int j = 0;
		//primeiro numero;
		for(;j < quant; j++)	{
			if(!usa[j]){
				usa[j] = true;
				sai.push_back(ent[j]);
				break;
			}
		}
		//segundo numero
		for(;j < quant; j++){
			if(!usa[j] && ent[j] > sai[sai.size() -1] && ent[j] % sai[sai.size() - 1] == 0){
				usa[j] = true;
				sai.push_back(ent[j]);
				break;
			}
		}
		//terceiro
		for(;j < quant; j++){
			if(!usa[j] && ent[j] > sai[sai.size() -1] && ent[j] % sai[sai.size() - 1] == 0){
				usa[j] = true;
				sai.push_back(ent[j]);
				break;
			}
		}
	}
	int n = 0;
	if(sai.size() == quant){
		for(int i = 0; i < quant/3; i++){
			for(int j = 0; j < 3; j++){
				cout << sai[n++] << " \n"[j == 2];
			}
		}
	}else{
		cout << -1 << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<tgmath.h>
#include<valarray>
#include<complex>
#include<time.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define rep(i,f,n) for(int i=f;i<n;i++)
#define mset(b,f) memset(b,f,sizeof(b))
#define pb(f) push_back(f)
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int >
#define real double
#define OO 99999999999
int read()
{
    int x;
    scanf("%d", &x);
    return x;
}
ll readL()
{
    ll x;
    scanf("%I64d", &x);
    return x;
}

//string s = "abcdefghijklmnopqrstuvwxyz";
int a[100000];
int b[100000];
int main()
{
    int n; cin>>n;
    rep(i,0,n) cin>>a[i];
    sort(a,a+n);
    b[0] = a[0];
    int pre = a[0];
    int k=1,cn = 0;
    for(int i=0;i<n/3;i++)
    {
        bool f = false;
        for(int j=1;j<n;j++)
        {

            if(a[j]!=-1)
            {
                if((a[j]>pre&&a[j]%pre==0)||(i>0&&j==1))
                {
                    b[k] = a[j]; k++;
                    pre = a[j];
                    a[j] = -1;
                    cn++;
                }
            }
            if((i==0&&cn==2)||(i>0&&cn==3)) { f = true; break; }
        }
        cn=0;
        pre = 1;
        if(!f) return cout<<-1,0;

    }
    for(int i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
        if((i+1)%3==0) cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<tgmath.h>
#include<valarray>
#include<complex>
#include<time.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define rep(i,f,n) for(int i=f;i<n;i++)
#define mset(b,f) memset(b,f,sizeof(b))
#define pb(f) push_back(f)
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int >
#define real double
#define OO 99999999999
int read()
{
    int x;
    scanf("%d", &x);
    return x;
}
ll readL()
{
    ll x;
    scanf("%I64d", &x);
    return x;
}

//string s = "abcdefghijklmnopqrstuvwxyz";
int a[100000];
int main()
{
    int n; cin>>n;
    int ones = 0,two = 0,th = 0,fo = 0,six = 0;
    rep(i,0,n)
    {
        cin>>a[i];
        if(a[i]==1) ones++;
        if(a[i]==2) two++;
        if(a[i]==3) th++;
        if(a[i]==4) fo++;
        if(a[i]==6) six++;
    }
    int s = n/3;
    if((fo+six)!=s||(two+th)!=s||ones!=s||(!six&&th>0)) return cout<<-1,0;
    for(int i=0;i<n/3;i++)
    {
       cout<<1<<" ";
       if(two)
       {
           cout<<2<<" ";
           two--;
           if(fo)
           {
             cout<<4;
             fo--;
           }
           else
           {
               cout<<6;
               six--;
           }
       }
       else
       {
           cout<<3<<" ";
           cout<<6;
           th--,six--;
       }
       cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<tgmath.h>
#include<valarray>
#include<complex>
#include<time.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define rep(i,f,n) for(int i=f;i<n;i++)
#define mset(b,f) memset(b,f,sizeof(b))
#define pb(f) push_back(f)
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int >
#define real double
#define OO 99999999999
int read()
{
    int x;
    scanf("%d", &x);
    return x;
}
ll readL()
{
    ll x;
    scanf("%I64d", &x);
    return x;
}

//string s = "abcdefghijklmnopqrstuvwxyz";
int a[100000];
int main()
{
    int n; cin>>n;
    int ones = 0,two = 0,th = 0,fo = 0,six = 0;
    rep(i,0,n)
    {
        cin>>a[i];
        if(a[i]==1) ones++;
        if(a[i]==2) two++;
        if(a[i]==3) th++;
        if(a[i]==4) fo++;
        if(a[i]==6) six++;
    }
    int s = n/3;
    if((fo+six)!=s||(two+th)!=s||ones!=s||(!six&&th>0)||(fo>two)) return cout<<-1,0;
    for(int i=0;i<n/3;i++)
    {
       cout<<1<<" ";
       if(two)
       {
           cout<<2<<" ";
           two--;
           if(fo)
           {
             cout<<4;
             fo--;
           }
           else
           {
               cout<<6;
               six--;
           }
       }
       else
       {
           cout<<3<<" ";
           cout<<6;
           th--,six--;
       }
       cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<tgmath.h>
#include<valarray>
#include<complex>
#include<time.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define rep(i,f,n) for(int i=f;i<n;i++)
#define mset(b,f) memset(b,f,sizeof(b))
#define pb(f) push_back(f)
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int >
#define real double
#define OO 99999999999
int read()
{
    int x;
    scanf("%d", &x);
    return x;
}
ll readL()
{
    ll x;
    scanf("%I64d", &x);
    return x;
}

//string s = "abcdefghijklmnopqrstuvwxyz";
int a[100000];
int main()
{
    int n; cin>>n;
    int ones = 0,two = 0,th = 0,fo = 0,six = 0;
    rep(i,0,n)
    {
        cin>>a[i];
        if(a[i]==1) ones++;
        if(a[i]==2) two++;
        if(a[i]==3) th++;
        if(a[i]==4) fo++;
        if(a[i]==6) six++;
    }
    int s = n/3;
    if((fo+six)!=s||(two+th)!=s||ones!=s||(th!=six)) return cout<<-1,0;
    for(int i=0;i<n/3;i++)
    {
       cout<<1<<" ";
       if(two)
       {
           cout<<2<<" ";
           two--;
           if(fo)
           {
             cout<<4;
             fo--;
           }
           else
           {
               cout<<6;
               six--;
           }
       }
       else
       {
           cout<<3<<" ";
           cout<<6;
           th--,six--;
       }
       cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<tgmath.h>
#include<valarray>
#include<complex>
#include<time.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define rep(i,f,n) for(int i=f;i<n;i++)
#define mset(b,f) memset(b,f,sizeof(b))
#define pb(f) push_back(f)
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int >
#define real double
#define OO 99999999999
int read()
{
    int x;
    scanf("%d", &x);
    return x;
}
ll readL()
{
    ll x;
    scanf("%I64d", &x);
    return x;
}

//string s = "abcdefghijklmnopqrstuvwxyz";
int a[100000];
int main()
{
    int n; cin>>n;
    int ones = 0,two = 0,th = 0,fo = 0,six = 0;
    rep(i,0,n)
    {
        cin>>a[i];
        if(a[i]==1) ones++;
        if(a[i]==2) two++;
        if(a[i]==3) th++;
        if(a[i]==4) fo++;
        if(a[i]==6) six++;
    }
    int s = n/3;
    if((fo+six)!=s||(two+th)!=s||ones!=s) return cout<<-1,0;
    for(int i=0;i<n/3;i++)
    {
       cout<<1<<" ";
       if(two)
       {
           cout<<2<<" ";
           two--;
           if(fo)
           {
             cout<<4;
             fo--;
           }
           else
           {
               cout<<6;
               six--;
           }
       }
       else
       {
           cout<<3<<" ";
           cout<<6;
           th--,six--;
       }
       cout<<"\n";
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[100005];
int num[10];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);

    for(int i=0;i<n;i++)
    {
        num[a[i]]++;
    }
    int flag=0;
    if((num[1]-num[2])>0||(num[1]-num[6])>0||(num[1]-num[4]-num[3])>0)
    {
        if(!num[5]&&!num[7])
        {
            if(num[1]&&num[2]&&num[4])
            {
                for(int i=0;i<num[1]-num[6];i++)
                printf("1 2 4\n");
                flag=1;
            }
            if(num[1]&&num[2]&&num[6])
            {
                 for(int i=0;i<num[1]-num[4]-num[3];i++)
                printf("1 2 6\n");
                flag=1;
            }
            if(num[1]&&num[3]&&num[6])
            {
                for(int i=0;i<num[1]-num[2];i++)
                printf("1 3 6\n");
                flag=1;
            }

        }
    }
    if(!flag)
    printf("-1\n");
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define dep(i,b,a) for (int i = (b); i >= (a); -- i)

using namespace std;
int num[10], n;
bool work() {
		  	if (n % 3) return 0;
		  	rep(i, 1, n) {
		  		int x;
				scanf("%d", &x);
				if (x <= 0 || x > 7) return 0;
				num[x] ++;
		  	}
			if (num[5] || num[7]) return 0;
			int a = num[4], c = num[3];
			int b = num[2] - a;
			if (b < 0) return 0;
			if (!(num[1]==a+b+c&&num[6]==b+c)) return 0;
			rep(i,1,a)
					  printf("1 2 4\n");
			rep(i,1,b) printf("1 2 6\n");
			rep(i,1,c) printf("1 3 6\n");
			return 1;
}
int main() {
		//  freopen(".in", "r", stdin);
		  scanf("%d", &n);
		  if (!work()) printf("-1\n");
		  return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string.h>
using namespace std;

int main(){
	int i,n,count1=0,count2=0,count3=0,count4=0,count6=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		if(a[i]==5||a[i]==7){
			cout<<-1;
			return 0;
		}
		if(a[i]==1) count1++;
		else if(a[i]==2) count2++;
		else if(a[i]==3) count3++;
		else if(a[i]==4) count4++;
		else count6++;
	}

	if(count1!=n/3){
		cout<<-1;
		return 0;
	}

	if(count4+count6==count2+count3&&count2>=count4){
		i=0;
		while(i<count4){
			cout<<1<<" "<<2<<" "<<4<<endl;
			i++;
		}
		i=0;
		while(i<count2-count4){
			cout<<1<<" "<<2<<" "<<6<<endl;
			i++;
		}
		i=0;
		while(i<count3){
			cout<<1<<" "<<3<<" "<<6<<endl;
			i++;
		}
	}
	else{
		cout<<-1;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int num[8];
    for(int i = 0; i < 8; i++)
        num[i] = 0;
    for(int i = 0; i < n; i++){
        int number;
        scanf("%d", &number);
        num[number]++;
    }
    //for(int i = 0; i < 8; i++)
        //printf("%d ", num[i]);
    int t = 100000, k =0;
    if(num[1] < t)
        t = num[1];
    if(num[2] < t)
        t = num[2];
    if(num[4] < t)
        t = num[4];
    if(t != 0){
        k = 1;
        for(int i = 0; i < t; i++)
            printf("1 2 4\n");
    }
    t = 100000;
    if(num[1] < t)
        t = num[1];
    if(num[2] < t)
        t = num[2];
    if(num[6] < t)
        t = num[6];
    if(t != 0){
        k = 1;
        for(int i = 0; i < t; i++)
            printf("1 2 6\n");
    }
    t = 100000;
    if(num[1] < t)
        t = num[1];
    if(num[3] < t)
        t = num[3];
    if(num[6] < t)
        t = num[6];
    if(t != 0){
        k = 1;
        for(int i = 0; i < t; i++)
            printf("1 3 6\n");
    }
    if(k == 0)
        printf("-1");
    return 0;
}


#include<stdio.h>

int n,a[1000000],i,j,inde,temp,flag=0,count1=0,count2=0,count3=0,count4=0,count6=0;

int main(void)

{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i] == 1) count1++;
		if(a[i] == 2) count2++;
		if(a[i] == 3) count3++;
		if(a[i] == 4) count4++;
		if(a[i] == 6) count6++;
	}

	for(i=0;i<n;i++)
	{
		if(a[i] == 5 || a[i] == 7) flag=-1;
		else if(count1 != n/3) flag=-1;
		else if( count6-count3+count4 != count2) flag=-1;
		else continue;
	}

	for(i=0;i<n-1;i++)
	{
		inde=i;
		for(j=i+1;j<n;j++)
		{
			if(a[inde] > a[j]) inde=j;
		}
		temp=a[i];
		a[i]=a[inde];
		a[inde]=temp;
	}

	if(flag == 0)
		for(i=0;i<n/3;i++)
		{
			printf("%d",a[i]);
			printf(" %d",a[i+n/3]);
			printf(" %d",a[i+2*n/3]);
			if(i != n/3-1) printf("\n");
		}
	if(flag == -1) printf("%d",-1);
	return 0;
 }


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[100005];
int num[10];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);

    for(int i=0;i<n;i++)
    {
        num[a[i]]++;
    }
    int flag=0;
    if((num[1]-num[2])>0||(num[1]-num[6])>0||(num[1]-num[4]-num[3])>0)
    {
        if(num[4]+num[6]==num[1]&&num[3]+num[2]==num[1])
        {
             if(!num[5]&&!num[7])
        {
            if(num[1]&&num[2]&&num[4])
            {
                for(int i=0;i<num[1]-num[6];i++)
                printf("1 2 4\n");
                flag=1;
            }
            if(num[1]&&num[2]&&num[6])
            {
                 for(int i=0;i<num[1]-num[4]-num[3];i++)
                printf("1 2 6\n");
                flag=1;
            }
            if(num[1]&&num[3]&&num[6])
            {
                for(int i=0;i<num[1]-num[2];i++)
                printf("1 3 6\n");
                flag=1;
            }

        }
        }

    }
    if(!flag)
    printf("-1\n");
    return 0;
}


#include<stdio.h>
int main()
{
    int n,a[10000],dui,r;
    static int jilu[8];
    int i,result;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
         scanf("%d",&a[i]);
         jilu[a[i]]++;
    }

    if(jilu[5]||jilu[7])
    {
        result =-1;
    }
    else
    {
        dui=n/3;
        if(jilu[1]==dui && (jilu[4]+jilu[6])==dui)
        {
            if(jilu[2]>=jilu[4])
            result=1;
            else
            result=-1;
        }
        else
        {
          result=-1;
        }
    }

    if(result==-1)
    printf("%d",result);
    else
    {
     r=jilu[2]-jilu[4];
     while(jilu[4]--)
     {
        printf("1 2 4\n");
     }
     while(r--)
     printf("1 2 6\n");
     while(jilu[3]--)
     printf("1 3 6\n");
    }
   return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int li[n];
    int ifexist = 1;
    int one = 0, two = 0, three = 0, four = 0, six = 0, other = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> li[i];
        switch (li[i])
        {
            case 1: one++; break;
            case 2: two++; break;
            case 3: three++; break;
            case 4: four++; break;
            case 6: six++; break;
            default : other++; break;
        }
    }
    if (other) cout << -1;
    else
    {
        if ((one == two + three) && (one == four + six))
        {
            if ((two < four) || (three > six))
            {
                cout << -1;
            }
            else
            {
                int grs = n/3;
                int ctgr = grs;
                while (four--)
                {
                    cout << "1 2 4\n";
                    two--;
                }
                while (two--)
                {
                    cout << "1 2 6\n";
                }
                while (three--)
                {
                    cout << "1 3 6\n";
                }
            }
        }
        else cout << -1;

    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n;
	scanf("%d",&n);
	int *p = new int[n];
	int i,temp;
	for(i=0;i<n;i++)
	{
		scanf("%d",p[i]);
	}
	for(i=0;i<n-1;i++)
	{
		int j = i;
		while(p[j]>p[j+1] && j< n)
		{
			temp = p[i+1];
			p[i+1]=p[i];
			p[i]=temp;
			j++;
		}
	}
	int*q = new int[n];
	int count=0, a = n/3;
	for(i=0;i<n&&count<=a;i++)
	{
		q[3*count]=p[i];
		int k=i+1;
		while(p[k]%p[i] != 0 && k<n)
		{
			k++;
		}
		if(k==n)
		{
			printf("-1\n");
			return 0;
		}
		else
		{
			q[3*count+1]=p[k];
			int l=k+1;
			while(p[l]%p[k] != 0 && l<n)
			{
				l++;
			}
			if(l==n)
			{
				printf("-1\n");
				return 0;
			}
			else
			{
				q[3*count+2]=p[k];
			}
		}
		count++;
	}
	for(i=0;i<count;i++)
	{
		printf("%d %d %d\n",&q[3*i],&q[3*i+1],&q[3*i+2]);
	}
	system("pause");
	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
#include <algorithm>
typedef long long int ll;
using namespace std;

int a[110000];
int main(void)
{
    int n;
    int _1num=0,_2num=0,_3num=0,_4num=0,_6num=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]==5 || a[i]==7){
            printf("-1\n");
            return 0;
        }
        if(a[i]==1){
            _1num++;
        }
        if(a[i]==2){
            _2num++;
        }
        if(a[i]==3){
            _3num++;
        }
        if(a[i]==4){
            _4num++;
        }
        if(a[i]==6){
            _6num++;
        }
    }
    if(_1num!=n/3 || (_2num+_3num)!=n/3 || (_4num+_6num)!=n/3 || _2num<_4num ||_6num<_3num){
        printf("-1\n");
        return 0;
    }
    else{
        if(_4num>0){
            printf("1 2 4\n");
        }
        if(_2num-_4num>0){
            printf("1 2 6\n");
        }
        if(_3num>0){
            printf("1 3 6\n");
        }
    }
    /*
    else{
        for(int i=0;i<_4num;i++){
            printf("1 2 4\n");
        }
        for(int i=0;i<_2num-_4num;i++){
            printf("1 2 6\n");
        }
        for(int i=0;i<_3num;i++){
            printf("1 3 6\n");
        }
    }
    */
    return 0;
}


#include <cstdio>
int main()
{
	int n;
	std::scanf("%d",&n);
	int num;
	int count1=0,count2=0,count3=0,count4=0,count6=0,count124=0,count126=0,count136=0;
	bool flag = true;
	for (int i=0;i<n;++i)
	{
		std::scanf("%d",&num);
		switch (num)
		{
			case 1:
			{
				++count1;
				break;
			}
			case 2:
			{
				++count2;
				break;
			}
			case 3:
			{
				++count3;
				break;
			}
			case 4:
			{
				++count4;
				break;
			}
			case 6:
			{
				++count6;
				break;
			}
			default:
			{
				flag = false;
				goto NO_ANSWER;
				break;
			}
		}
	}
	if (flag)
	{
		if ((count1>=count6) and (count6>=count3))
		{
			count136 += count3;
			count1 -= count3;
			count6 -= count3;
			count3 -= count3;
		}
		else
		{
			flag = false;
			goto NO_ANSWER;
		}
		if ((count1==count2) and (count1==count4+count6))
		{
			count124 = count4;
			count126 = count6;
		}
		else
		{
			flag = false;
			goto NO_ANSWER;
		}
		for (int i=0;i<count124;++i) std::printf("1 2 4\n");
		for (int i=0;i<count126;++i) std::printf("1 2 6\n");
		for (int i=0;i<count136;++i) std::printf("1 3 6\n");
	}
	NO_ANSWER:
	if (not flag) std::printf("-1");
}


#include <bits/stdc++.h>
using namespace std;
int num[8];
int main()
{
	int n,s,flag = 1;
	scanf("%d",&n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d",&s);
		if (s == 5 || s == 7)
		{
			flag = 0;
		}
		else
		{
			num[s]++;
		}
	}
	if (flag == 1 && num[1] == num[2] + num[3] && num[2] > num[4] && num[1] == num[4] + num[6])
	{
		for (int i = 0;i < num[4];i++)
		{
			printf("1 2 4\n");
		}
		for (int i = 0;i < num[2] - num[4];i++)
		{
			printf("1 2 6\n");
		}
		for (int i = 0;i < num[3];i++)
		{
			printf("1 3 6\n");
		}
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}


#include<stdio.h>

int main() {
    int n;
    int a;
    int b[10];
    int res[100000][3];
    scanf("%d", &n);
    for(int i=0; i < n;i++) {
        scanf("%d", &a);
        b[a]++;
    }

    int x = 0;
    for(int i=7; i > 0;i--) {
        if( b[i] == 0) {
            continue;
        }
        int now = i;
        res[x][0] = i;
        b[i]--;
        for(int c=1; c < 3; c++) {
            bool has = false;
            for(int j=now; j > 0; j--) {
                // printf("%d %d %d\n", i, j, b[j]);
                if (now % j != 0 || b[j] == 0) {
                    continue;
                }
                b[j]--;
                now = j;
                has = true;
                res[x][c] = j;
                // printf("%d\n", j);
                break;
            }

            if (!has) {
                printf("-1\n");
                return 0;
            }
        }
        x++;
    }

    for (int i = 0; i < x; i++){
        printf("%d %d %d\n", res[i][2], res[i][1], res[i][0]);
    }

    return 0;
}


#include<stdio.h>

int main() {
    int n;
    int a;
    int b[10];
    int res[100000][3];
    scanf("%d", &n);
    for(int i=0; i < n;i++) {
        scanf("%d", &a);
        b[a]++;
    }

    int x = 0;
    for(int i=7; i > 0;i--) {
        if( b[i] == 0) {
            continue;
        }
        int now = i;
        res[x][0] = i;
        b[i]--;
        for(int c=1; c < 3; c++) {
            bool has = false;
            for(int j=now-1; j > 0; j--) {
                // printf("%d %d %d\n", i, j, b[j]);
                if (now % j != 0 || b[j] == 0) {
                    continue;
                }
                b[j]--;
                now = j;
                has = true;
                res[x][c] = j;
                // printf("%d\n", j);
                break;
            }

            if (!has) {
                printf("-1\n");
                return 0;
            }
        }
        x++;
    }

    for (int i = 0; i < x; i++){
        printf("%d %d %d\n", res[i][2], res[i][1], res[i][0]);
    }

    return 0;
}


#include<stdio.h>

int main() {
    int n;
    int a;
    int b[10];
    int res[100000][3];
    scanf("%d", &n);
    for(int i=0; i < n;i++) {
        scanf("%d", &a);
        b[a]++;
    }

    int x = 0;
    for(int i=7; i > 0;i--) {
        while( b[i] != 0) {
            int now = i;
            res[x][0] = i;
            b[i]--;
            for(int c=1; c < 3; c++) {
                bool has = false;
                for(int j=now-1; j > 0; j--) {
                    // printf("%d %d %d\n", i, j, b[j]);
                    if (now % j != 0 || b[j] == 0) {
                        continue;
                    }
                    b[j]--;
                    now = j;
                    has = true;
                    res[x][c] = j;
                    // printf("%d\n", j);
                    break;
                }

                if (!has) {
                    printf("-1\n");
                    return 0;
                }
            }
            x++;
        }
    }

    for (int i = 0; i < x; i++){
        printf("%d %d %d\n", res[i][2], res[i][1], res[i][0]);
    }

    return 0;
}