from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
acc = 0
cnt = defaultdict(int)
cnt[0] = 1
ans = 0

for Ai in A:
    acc += Ai
    ans += cnt[acc]
    cnt[acc] += 1

print(ans)