#include<iostream>
#include<set>
using namespace std;
multiset< int > Set;
int main()
{
int i,n,target,k,x,numOfElements,mx=-100000000,mn=100000000;
cin>>numOfElements;
for(i=0,n=0,target=1,k=0;i<numOfElements;i++)
{
cin>>x; // input
mn=min(mn,x);
mx=max(mx,x);
Set.insert(x); //inserting in the set
k++;
if(target==k) {
n++; // n is incremented
//Code for finding nth number in the set
int l=mn,r=mx;
while(l<=r)
{
int m=(l+r)>>1;
multiset<int>::iterator it=Set.lower_bound(m),itt=Set.upper_bound(m);
int d=distance(Set.begin(),it),D=distance(Set.begin(),itt);
if(d<=n-1 && D>n-1) // it is nth element of multiset
{
cout<<(*it)<<endl;
break;
}
else if(d>n-1) r=m-1;
else l=m+1;
}
///
k=0;
target++; // next target
}
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHNldD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgptdWx0aXNldDwgaW50ID4gU2V0OwoKaW50IG1haW4oKSAKewoJaW50IGksbix0YXJnZXQsayx4LG51bU9mRWxlbWVudHMsbXg9LTEwMDAwMDAwMCxtbj0xMDAwMDAwMDA7CgljaW4+Pm51bU9mRWxlbWVudHM7Cglmb3IoaT0wLG49MCx0YXJnZXQ9MSxrPTA7aTxudW1PZkVsZW1lbnRzO2krKykKCXsKCQljaW4+Png7ICAvLyBpbnB1dAoJCW1uPW1pbihtbix4KTsKCQlteD1tYXgobXgseCk7CgkJU2V0Lmluc2VydCh4KTsgLy9pbnNlcnRpbmcgaW4gdGhlIHNldAoJCWsrKzsKCQlpZih0YXJnZXQ9PWspIHsKCQkJbisrOyAvLyBuIGlzIGluY3JlbWVudGVkCgkJCS8vQ29kZSBmb3IgZmluZGluZyBudGggbnVtYmVyIGluIHRoZSBzZXQKCgkJCWludCBsPW1uLHI9bXg7CgkJCXdoaWxlKGw8PXIpCgkJCXsKCQkJCWludCBtPShsK3IpPj4xOwoJCQkJbXVsdGlzZXQ8aW50Pjo6aXRlcmF0b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