#include <iostream>

using namespace std;


int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        int arr[1010] = {0};
        for (int i = 0; i < n; i++) {
            int t;
            cin >> t;
            arr[t]++;
        }
        int K;
        cin >> K;
        for (int i = 0; i < 1010; i++) {
            if (arr[i] != 0) {
                K--;
            }
            if (K == 0) {
                cout << i << endl;
                break;
            }
        }

    }
    return 0;
}