def count_zero(arr, idx):
    w, cnt = 0, 0
    for i in range(idx, len(arr)):
        w += arr[i]
        if w == 0:
            cnt += 1

    return w, cnt


n = int(input())
a = list(map(int, input().split()))

comb = 0
s, c = count_zero(a, 0)
comb += c
s2 = s
for i in range(1, n):
    s2 = s2 - a[i-1] - a[i]
    if s == s2:
        res = count_zero(a, i)
        comb += res[1]
        s2 -= a[i]

    s2 += a[i]

print(comb)
