   def solve(A):
    cumsum = [0]
    for elem in A:
        cumsum.append(cumsum[-1]+elem)
    d = dict()
    for i in cumsum:
        try:
            d[i] += 1
        except:
            d[i] = 1
    res = 0
    for value in d.values():
        res += (value * (value - 1)) // 2
    return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    res = solve(A)
    print(res)

main()