
#include <bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
priority_queue<ll>a;//大根堆
priority_queue<ll,vector<ll>,greater<ll>>b;//小根堆
int n;
cin>>n;
for(int i=1;i<=n;i++){
ll x;
cin>>x;
if(b.empty()||x>=b.top()){
b.push(x);
}
else{
a.push(x);
}
int k=(i+1)/2;
while(b.size()>k){
a.push(b.top()),b.pop();
}
while(b.size()<k){
b.push(a.top()),a.pop();
}
if(i%2==1){
cout<<b.top()<<endl;
}
}
return 0;
}