from math import factorial
n = int(input())
a = list(map(int,input().split()))
all = [0 for N in range(n + 1)]
all[0] = a[0]
for N in range(1,n):
        all[N] = all[N - 1] + a[N]
all_sort = sorted(all)
num = []
mae = all_sort[0]
cnt = 0
alls = 0
for i in all_sort:
        if i == mae:
                cnt += 1
        else:
                if cnt != 1:
                        num.append(cnt)
                cnt = 1
        mae = i
if cnt != 1:
        num.append(cnt)
for i in num:
        a = factorial(i) / factorial(2) / factorial(i - 2)
        alls += a
print(int(alls))