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])

dict_S = {}
for i in list_S:
    if i in dict_S:
        dict_S[i] = 1
    else:
        dict_S[i] += 1

for v in dict_S.values():
    ans += v * (v-1) // 2

print(ans)