from collections import Counter
N = int(input())
A = list(map(int,input().split()))

s = 0
S = [0]
for a in A:
    s += a
    S.append(s)
C = Counter(S)

ans = 0
for c in C.values():
    ans += c * (c-1) // 2
print(ans)