N = int(input())
A_list = list(map(int, input().split()))
import math
#部分列の和を考えるなら累積和を
ruiseki_A_list = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        ruiseki_A_list[i] = A_list[i]
    else:
        ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]

#元のある区間の総和が知りたい

ruiseki_A_list.insert(0,0)
ans = 0

ruiseki_A_list.sort()
kosuu = [1]
k = 0
for i in range(N):
    if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:
        kosuu[k] += 1
    else:
        k += 1
        kosuu.append(1)
kosuu[-1] += 1
print(kosuu)
for num in kosuu:
    ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))

print(int(ans))