// https://www.geeksforgeeks.org/given-sorted-array-number-x-find-pair-array-whose-sum-closest-x/
#include <iostream>
using namespace std;
int main(){
int n,x;
cin>>n;
int a[n];
for (int i=0;i<n;i++)
cin>>a[i];
cout << "Enter the search element:";
cin>>x;
int i=0,j=n-1;
int sum = INT_MAX, l ,r;
while(i <= j){
int k = abs (x - a[i] - a[j]);
if (k < sum) {
sum = k;
l=i;
r=j;
}
if (a[i]+a[j] < x)
i++;
else
j--;
}
cout << a[l] << " and " << a[r];
}