# cook your dish here
import numpy as np
n =int(input())
a = list(map(int,input().split()))	


d = np.ones((n,n))

c = 0

if n == 1:
    if a[0]== 0:
        print(1)
    else:
        print(0)
    quit()

for i in range(0,n):
    d[0][i] = sum(a[:i+1:])
    if d[0][i] == 0:
        c += 1
for t in range(0,n-1):
    s = 0
    while s <=t:
        d[s+1][t+1] = d[s][t]-a[s]+a[t+1]
        if d[s+1][t+1] == 0:
            c += 1
        s += 1


print(c)