n = int(input())
a = list(map(int, input().split()))

acc = [0 for i in range(n+1)]
for i in range(n):
    acc[i+1] = a[i] + acc[i]

ans = [0 for i in range(n+1)]
for i in range(n+1):
    ans[acc[i]] += 1

cnt = 0
for i in range(len(a)+1):
    cnt += ans[i]*(ans[i]-1)//2

print(cnt)