def push(x):
stack.append(x)
def pop():
stack.pop()
K = int(input())
stack = []
for _ in range(K):
num = int(input())
pop() if num == 0 else push(num)
print(sum(stack))
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
백준 18258번(python) (0) | 2020.05.03 |
---|---|
백준 4949번(python) (0) | 2020.05.02 |
백준 2004번(python) (0) | 2020.04.28 |
백준 1676번(python) (0) | 2020.04.27 |
백준 9375번(python) (0) | 2020.04.20 |