import sys
import numpy as np
input = sys.stdin.buffer.readline
N = int(input())
A = np.array(list(map(int, input().split())))

# print(A.cumsum())

ans = 0
cumsum = A.cumsum()
# print(cumsum)
for _ in range(len(cumsum)):
    ans += np.count_nonzero(cumsum == 0)
    cumsum = cumsum[1:] - cumsum[0]
    # print(cumsum)
print(ans)
