# -*- coding: utf-8 -*-

N = int(input())
numbers = map(int, input().split())


def countSubZeroRange(numbers):
    partialSum = 0
    histogram = {}
    for number in numbers:
        partialSum += number
        histogram[partialSum] += 1
    
    zeroSumCounts = 0
    for column in histogram:
        zeroSumCounts += column - 1
    
    return zeroSumCounts


print(countSubZeroRange(numbers))
