N = int(input())
A = [i for i in map(int, input().split())]

def search(arr):
    if len(arr) == 1:
        return arr, arr, arr.count(0)

    l_left, l_right, l_count = search(arr[0:len(arr)//2])
    r_left, r_right, r_count = search(arr[len(arr)//2:])

    left = l_left + [l_left[-1] + i for i in r_left]
    right = [r_right[0] + i for i in l_right] + r_right
    count = l_count + r_count + [i+j for i in l_right for j in r_left].count(0)

    return left, right, count

l, r, c = search(A)
print(c)
