import sys
input = sys.stdin.readline
n = int(input())
stack = []
for _ in range(n):
num = int(input())
if num == 0:
stack.pop()
else:
stack.append(num)
print(sum(stack))
'문제풀이 > 백준(Boj) 문제풀이' 카테고리의 다른 글
[백준][DFS/BFS] 2606. 바이러스 (파이썬/Python) (0) | 2021.10.23 |
---|---|
[백준][스택] 9012. 괄호(파이썬/Python) (0) | 2021.10.22 |
[백준][스택] 10828. 스택 (파이썬/Python) (0) | 2021.10.22 |
[백준][DFS/BFS] 2178. 미로 탐색 (파이썬/Python) (0) | 2021.10.12 |
[백준][동적 계획법1] 13699. 점화식 (파이썬/Python) (0) | 2021.10.12 |