from math import *

def comb(n, r):
    ''' nCr '''
    if n == 1:
        return 0
    return int(factorial(n)/(factorial(r)*factorial(n-r)))

N = int(input())
a = [int(a_i) for a_i in input().split()]
s = []  # s[i] = a[0]からa[i+1]までの総和
sum = 0
for i in range(N):
    sum += a[i]
    s.append(sum)
ans = 0
s.sort()
val = float('inf')  # 前から見ていくときのs[i]の値
for s_i in s:
    if s_i == val:
        continue
    val = s_i
    if val == 0:
        ans += s.count(0) + comb(s.count(0), 2)
    else:
        ans += comb(s.count(val), 2)
print(ans)
