import math

N = int(input())
A = list(map(int, input().split()))

def solve():
    ans = 0
    sums = [0]
    sum_val = 0
    for i, A_i in enumerate(A):
        sum_val += A_i
        sums.append(sum_val)
    for i in set(sums):
        cnt = sums.count(i)
        if cnt == 1:
            ans += 0
        else:
            ans += (cnt)*(cnt-1)//2
    print(ans)


if __name__ == '__main__':
    solve()