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

ans = 0
b.sort()

for i in range(n+1):
    if i == 0:
        x = b[0]
        m = 1
    else:
        if x == b[i]:
            m += 1
            if i == n:
                ans += m*(m-1)//2
            else:
                if m != 1:
                    ans += m*(m-1)//2
                    m = 1
print(ans)
