import math
N = int(input())
l = [int(x) for x in input().split()]
s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + l[i]
s.sort()
ans = 0
owari = False
for i in range(N+1):
    if owari:
        break
    x = s.pop(0)
    count = 1
    for j in range(N+1):
        if not s:
            owari = True
            if count != 1:
              ans += math.factorial(count) // (math.factorial(count-2)*2)
            break
        elif x == s[0]:
            s.pop(0)
            count += 1
        elif count != 1:
            ans += math.factorial(count) // (math.factorial(count-2)*2)
            break
        else:
            break
print(ans)