def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [a[0]]
    for i in range(n-1):
        ruiseki.append(ruiseki[i]+a[i+1])
    ans = 0
    for i in range(n-1):
        if ruiseki[i] == 0:
            ans += 1
        for j in range(i+1, n):
            if ruiseki[j]-ruiseki[i] == 0:
                ans += 1
    if ruiseki[-1] == 0:
        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()