from collections import defaultdict
def solve():
    N = int(input())
    progression = list(map(int, input().split()))
    cuml = [0]*(N+1)
    for i in range(len(progression)):
        cuml[i+1] = cuml[i] + progression[i]
    cuml_dic = defaultdict(list)
    for i, num in enumerate(cuml):
        cuml_dic[num].append(i)
    ans = 0
    for i in range(1, N+1):
        if cuml[i] == 0:
            ans += 1
        for index in cuml_dic[cuml[i]]:
            if index > i:
                ans += 1
    print(ans)



solve()