plafle @ 2019-02-04 15:51:54
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
priority_queue<int> h2;
priority_queue<int,vector<int>,greater<int> > h1;
int n,x,y;
void work() {
if (h1.top()<h2.top()) {
x=h1.top();
y=h2.top();
h1.pop();
h1.push(y);
h2.pop();
h2.push(x);
}
}
int main() {
//freopen("p1168.in","r",stdin);
//freopen("p1168.out","w",stdout);
scanf("%d",&n);
h2.push((-1)*1e9);
scanf("%d",&x);
printf("%d\n",x);
h1.push(x);
for (int i=1; i<=(n >> 1); i++) {
scanf("%d",&x);
h1.push(x);
work();
scanf("%d",&x);
h2.push(x);
work();
printf("%d\n",h1.top());
}
return 0;
}