https://www.acmicpc.net/problem/11286
(절댓값, 원래 값) 튜플 생성해서 heapq에 삽입할 각 숫자에 대해 (abs(숫자), 숫자) 형태의 튜플을 만들어 힙에 삽입한다
import heapq
import sys
n = int(sys.stdin.readline().rstrip())
heap = []
for _ in range(n):
num = int(sys.stdin.readline().rstrip())
if num != 0:
heapq.heappush(heap, (abs(num), num))
else:
if len(heap) == 0:
print(0)
else:
print(heapq.heappop(heap)[1])```