import numpy as np
n = int(input())
a = [int(i) for i in input().split()]

cumsum = np.cumsum(a)

cnt = 0
for i in range(n):
    if cumsum[i] == 0:
        cnt += 1
for i in range(n-1):
    for j in range(i+1, n):
        if cumsum[j]-cumsum[i] == 0:
            cnt += 1

print(cnt)
