import java.util.*;
public class targetsum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
n=sc.nextInt();
int [] ar = new int [n];
for(int i=0;i<ar.length;i++) {
ar[i]=sc.nextInt();
}
int target=sc.nextInt();
//sorting to get in ascending order
for(int i=0;i<ar.length;i++) {
for(int j=0;j<ar.length;j++) {
if(j==ar.length-1) {
break;
}
else {
if(ar[j]>ar[j+1]) {
int temp=ar[j];
ar[j]=ar[j+1];
ar[j+1]=temp;
}
}
}
}
for(int i=0;i<ar.length;i++) { //finding the sum pair
for(int j=i;j<ar.length;j++) {
if(ar[i]+ar[j]==target) {
System.out.println(ar[i]+" "+"and"+" "+ar[j]);
j=ar.length;
}
}
}
}
}