import numpy as np
import copy as cp

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

def nck(n,k):
    if 0 <= k <= n:
        ret = 1
        for i in range(k):
            ret = ret*(n-i)/(i+1)
        return ret
    return 0

def numzero(a):
    if a <= 1:
        return 0
    elif a == 2:
        return 1
    else: return nck(a,2)

cumsum = [0]
s = 0
for i in range(len(a)):
    s += a[i]
    cumsum.append(s)
#print(cumsum)

v = cp.deepcopy(cumsum)
v.sort()
cnt = np.zeros(v[-1]-v[0]+1)

for i in range(len(cumsum)):
    #print(i,cumsum[i])
    cnt[cumsum[i]-v[0]] += 1
    #print(cnt)
#print(cnt)

ans = 0
for i in range(len(cnt)):
    ans += numzero(cnt[i])
print(int(ans))