https://www.acmicpc.net/problem/1655
import heapq
import sys
input = sys.stdin.readline
n = int(input())
ans = []
leftHeap = [] # 중간값보다 작은 수 , 최대힙
rightHeap = [] # 중간값보다 큰 수 , 최소힙
for i in range(n):
num = int(input())
if len(leftHeap) == len(rightHeap):
heapq.heappush(leftHeap, (-num, num))
else:
heapq.heappush(rightHeap, (num, num))
if rightHeap and leftHeap[0][1] > rightHeap[0][0]:
min = heapq.heappop(rightHeap)[0]
max = heapq.heappop(leftHeap)[1]
heapq.heappush(leftHeap, (-min, min))
heapq.heappush(rightHeap, (max, max))
ans.append(leftHeap[0][1])
for j in ans:
print(j)