import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.Collections;
import java.util.PriorityQueue;
/**
* @author 은서파
* @since 2022/05/30
* @see
* @git
* @youtube
* @performance 34916 404
* @category #
* @note
*/
public class BJ_G2_01655_가운데를말해요 {
private static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
private static StringBuilder output = new StringBuilder();
private static int N;
private static PriorityQueue<Integer> maxPq, minPq;
public static void main(String[] args) throws IOException {
input = new BufferedReader(new StringReader(src));
N = Integer.parseInt(input.readLine());
maxPq = new PriorityQueue<>(Collections.reverseOrder()); // 역순(큰 값 부터 나올 수 있게)
minPq = new PriorityQueue<>(); // 작은 값이 맨 앞에
boolean isOdd = true;
for(int n=0; n<N; n++){
int num = Integer.parseInt(input.readLine());
if(isOdd){
maxPq.offer(num);
}else{
minPq.offer(num);
}
// 자리 교환 필요
if(!minPq.isEmpty() && maxPq.peek() > minPq.peek()){
minPq.offer(maxPq.poll());
maxPq.offer(minPq.poll());
}
// 중간값은 왼쪽 maxPq에 존재
output.append(maxPq.peek()).append("\n");
isOdd = !isOdd;
}
System.out.println(output);
}
// REMOVE_START
private static String src = "7\n"
+ "1\n"
+ "5\n"
+ "2\n"
+ "10\n"
+ "-99\n"
+ "7\n"
+ "5";
// REMOVE_END
}