https://embed.notion-tools.com/block/imglink/?t=white&i=https%3A%2F%2Fimg1.daumcdn.net%2Fthumb%2FR1280x0%2F%3Fscode%3Dmtistory2%26fname%3Dhttps%253A%252F%252Fblog.kakaocdn.net%252Fdn%252FbmRdOo%252Fbtq64ypzNQQ%252Fd4B2TxhKh3FglqKon4fSiK%252Fimg.png&l=https%3A%2F%2Fdailylifeofdeveloper.tistory.com%2F197
💢 시간초과...ㅠ
arr = []
N = int(input())
for i in range(N):
cmd = int(input())
if cmd != 0:
arr.append(cmd)
else:
if len(arr) == 0:
print(0)
else:
print(max(arr))
arr.remove(max(arr))