from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
S = list(accumulate(A))
print(A)
print(S)


cnt = 0
tmp = 0
for i in range(n):
  if S[i] == 0 or S[i] == tmp:
    cnt += 1
    tmp = S[i-1]
print(cnt)