#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
struct suma
{
suma(int tx, int ty, int tz)
{
x = tx;
y = ty;
z = tz;
s = tx + ty + tz;
}
int x, y, z;
int s;
};
ifstream in("loto.in");
ofstream out("loto.out");
int n, s;
int v[105];
vector<suma> sum;
void citire()
{
in >> n >> s;
for(int i = 1; i <= n; ++i)
in >> v[i];
}
bool comp(suma x, int val)
{
if(x.s < val) return true;
return false;
}
bool cmp(suma x, suma y)
{
if(x.s < y.s)
return true;
return false;
}
void rezolvare()
{
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
for(int k = 1; k <= n; ++k)
{
sum.push_back(suma(v[i], v[j], v[k]));
}
sort(sum.begin(), sum.end(), cmp);
int rasp[6];
rasp[0] = -1;
for(int i = 0; i < sum.size(); ++i)
{
int rest = s - sum[i].s;
auto it = lower_bound(sum.begin(), sum.end(), rest, comp);
if(it->s == rest)
{
rasp[0] = sum[i].x;
rasp[1] = sum[i].y;
rasp[2] = sum[i].z;
rasp[3] = it->x;
rasp[4] = it->y;
rasp[5] = it->z;
}
}
if(rasp[0] != -1)
{
for(int i = 0; i < 6; ++i)
out << rasp[i] << " ";
}
else
out << -1;
}
int main()
{
citire();
rezolvare();
return 0;
}