#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int a[N];
int quick_sort(int a[], int l, int r, int k){
if (l >= r){
return a[l];
}
int i = l - 1;
int j = r + 1;
int x = a[l + r >> 1];
while (i < j){
do{
i ++;
}while (a[i] < x);
do{
j --;
}while (a[j] > x);
if (i < j){
swap(a[i], a[j]);
}
}
int len_l = j-l+1;
if (k <= len_l){
return quick_sort(a, l, j, k);
}
else{
return quick_sort(a, j+1, r, k-len_l);
}
}
int main(){
int n;
while (cin >> n){
for (int i=0; i<n; i++){
cin >> a[i];
}
int k;
cin >> k;
unordered_set<int> s;
for (int i = 0; i < n; i++) {
s.insert(a[i]);
}
int i = 0;
for (auto x : s) {
a[i++] = x;
}
n = s.size();
int res = quick_sort(a, 0, n-1, k);
cout << res << endl;
}
return 0;
}