from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
f = [1]*(N+1)


def fact():
    for i in range(1, N):
        f[i+1] = f[i]*(i+1)


def comb(n, r):
    return f[n]//(f[r]*f[n-r])


a = accumulate(A)
C = Counter(a)

ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v, 2)
print(ans)
