import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder("");
PriorityQueue<Integer> maxHeap = new PriorityQueue<Integer>((element1, element2) -> element2 - element1);
PriorityQueue<Integer> minHeap = new PriorityQueue<Integer>();
int N = Integer.parseInt(br.readLine());
int num = 0;
while (N-- > 0) {
num = Integer.parseInt(br.readLine());
if (maxHeap.size() <= minHeap.size()) {
maxHeap.offer(num);
} else {
minHeap.offer(num);
}
if (!minHeap.isEmpty() && maxHeap.peek() > minHeap.peek()) {
maxHeap.offer(minHeap.poll());
minHeap.offer(maxHeap.poll());
}
sb.append(maxHeap.peek()).append("\n");
}
System.out.print(sb);
}
}