def make_sumlist(n,a):
    cnt = 0
    sum_list = []
    for start in range(n):
        sum_i = a[start]
        sum_list.append(sum_i)
        for last in range(start+1,n):
            sum_i += a[last]
            sum_list.append(sum_i)
            if sum_i == 0:
                cnt += 1
    return cnt

def main():
    # 1.input
    n = int(input())
    a = list(map(int, input().split()))
#    n = 6
#    a = [1,2,-4,2,2,-2]
    numofZero = make_sumlist(n,a)
    print(numofZero)


if __name__ == "__main__":
    main()