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

s = [0]*(n+1)

for i,e in enumerate(a):
    s[i+1] = s[i] + e

ans = 0
for i in range(1,n+1):
    sl = sorted(s[:i])
    l = bisect.bisect_left(sl,s[i])
    r = bisect.bisect_right(sl,s[i])

    ans += r-l

print(ans)
