#include <functional> #include <iostream> #include <queue> using namespace std; int main() { int n; while(cin>>n){ priority_queue<int,vector<int>,greater<int>> smallerHeap; for(int i=0;i<n;i++){ int a; cin>>a; smallerHeap.push(a); } int o; cin>>o; int k=1; int kmin=smallerHeap.top(); smallerHeap.pop(); while(k<o){ if(kmin==smallerHeap.top()){ smallerHeap.pop(); continue; } else{ k++; kmin=smallerHeap.top(); smallerHeap.pop(); } } cout<<kmin<<endl; } }