#include
#include
using namespace std;
int main()
{
int n,a[1000],i,target,j;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
cin>>target;
sort( a , a + n);
for(i=0;i<n;i++)
{
for(j=i+1;j<n-1;)
{
while (j<n-1)
{
if (a[i]+a[n-1]+a[j]==target)
{
cout<<a[i]<<", "<<a[j]<<" and "<<a[n-1]<<endl;
}
if(a[i]+a[n-1]+a[j]>target)
{ n--; }
else j++;
}
}
}
return 0;
}