실버1 문제 실패
import heapq
import sys
n = int(sys.stdin.readline().rstrip())
arr = []
for _ in range(n):
x = int(sys.stdin.readline().rstrip())
if ( x != 0 ):
heapq.heappush(arr, [abs(x), x])
else:
if ( len(arr) == 0 ):
print(0)
else:
num = heapq.heappop(arr)[1]
print(num)