#include <bits/stdc++.h>
using namespace std;
int main() {
int M, N;
cin >> M;
vector<int> numeros(M);
for(int i = 0; i < M; i++) {
cin >> numeros[i];
}
cin >> N;
int clave = INT_MAX;
for(int i = 0; i < M; i++) {
if(numeros[i] > N && numeros[i] < clave) {
clave = numeros[i];
}
}
cout << clave << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGludCBNLCBOOwogICAgY2luID4+IE07CiAgICB2ZWN0b3I8aW50PiBudW1lcm9zKE0pOwogICAgZm9yKGludCBpID0gMDsgaSA8IE07IGkrKykgewogICAgICAgIGNpbiA+PiBudW1lcm9zW2ldOwogICAgfQogICAgY2luID4+IE47CiAgICAKICAgIGludCBjbGF2ZSA9IElOVF9NQVg7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgTTsgaSsrKSB7CiAgICAgICAgaWYobnVtZXJvc1tpXSA+IE4gJiYgbnVtZXJvc1tpXSA8IGNsYXZlKSB7CiAgICAgICAgICAgIGNsYXZlID0gbnVtZXJvc1tpXTsKICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGNsYXZlIDw8IGVuZGw7CiAgICByZXR1cm4gMDsKfQo=