
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]
    ans = 0
    for i in range(1, N+1):
        if cuml[i] == 0:
            ans += 1
        for j in range(i+1, N+1):
            # print(cuml[i], cuml[j])
            if cuml[i] == cuml[j]:
                ans += 1
        # print()
    print(ans)

solve()