#include <stdio.h>
int main ()
{
long long int n ,min ,a [100007] , m , i ,j ,s,w, p ,d,k ;
while (scanf ("%lld",&n) == 1 )
{
for (i=1 ; i<=n ; i++)
{
scanf ("%lld",&a [i] ) ;
}
scanf ("%lld",&m) ;
min = 1000000 ;
for (p=1 ; p<=n-1 ; p++)
{
for (k =p+1 ; k<=n ; k++)
{
if (a[p] + a[k] == m)
{
if (a[p]>a[k] ) d = a[p] - a[k] ;
else d = a[k] - a[p] ;
if (min > d)
{
min = d ;
s= k ;
w= p ;
}
}
}
}
if (a[s] > a[w]) printf ("Peter should buy books whose prices are %lld and %lld.\n",a[w] ,a[s] ) ;
else printf ("Peter should buy books whose prices are %lld and %lld.\n",a[s] ,a[w] ) ;
printf ("\n") ;
}
return 0 ;
}
int main ()
{
long long int n ,min ,a [100007] , m , i ,j ,s,w, p ,d,k ;
while (scanf ("%lld",&n) == 1 )
{
for (i=1 ; i<=n ; i++)
{
scanf ("%lld",&a [i] ) ;
}
scanf ("%lld",&m) ;
min = 1000000 ;
for (p=1 ; p<=n-1 ; p++)
{
for (k =p+1 ; k<=n ; k++)
{
if (a[p] + a[k] == m)
{
if (a[p]>a[k] ) d = a[p] - a[k] ;
else d = a[k] - a[p] ;
if (min > d)
{
min = d ;
s= k ;
w= p ;
}
}
}
}
if (a[s] > a[w]) printf ("Peter should buy books whose prices are %lld and %lld.\n",a[w] ,a[s] ) ;
else printf ("Peter should buy books whose prices are %lld and %lld.\n",a[s] ,a[w] ) ;
printf ("\n") ;
}
return 0 ;
}