# 백준 3273번 두 수의 합

## Solution

import java.io.*;
import java.util.*;

public class Main {
static StringBuilder sb = new StringBuilder();

static int n, S;
static int[] a;

static void input() {
n = scan.nextInt();
a = new int[n + 1];
for (int i = 1; i <= n; i++) {
a[i] = scan.nextInt();
}
S = scan.nextInt();
}

static void pro() {
Arrays.sort(a, 1, n + 1);

int L = 1;
int R = n;
int sum;

while (L < R) {
sum = a[L] + a[R];
if (sum == S) {
L++;
R--;
} else if (sum < S) {
L++;
} else {
R--;
}
}

}

public static void main(String[] args) {
input();
pro();
}

StringTokenizer st;

}

public FastReader(String s) throws FileNotFoundException {
}

String next() {
while (st == null || !st.hasMoreElements()) {
try {
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

long nextLong() {
return Long.parseLong(next());
}

double nextDouble() {
return Double.parseDouble(next());
}

String nextLine() {
String str = "";
try {
}