N = int(input())
a = list(map(int, input().split()))
s = [0 for i in range(N+1)]
for i in range(N):
    s[i+1] = s[i] + a[i]
#s[i+1]にはa[0]からa[i]までの総和

nums = [0 for i in range(N+1)]
for i in range(N+1):
    nums[s[i]] += 1

ans = 0
for i in range(N+1):
    ans += nums[i]*(nums[i]-1)/2

print(int(ans))