n = int(input())
a = list(map(int,input().split()))
list_S = [0]
ans = 0
for i in range(n):
    list_S.append(list_S[i] + a[i])

list_S.sort()
pre = list_S[0]
acc = 1
for i in range(1,n+1):
    if list_S[i] == pre:
        acc += 1
    else:
        ans += acc * (acc-1) // 2
        pre = list_S[i]
        acc = 1

ans += acc * (acc-1) // 2

    
print(ans)
