import numpy as np
from math import factorial
from collections import Counter

n = int(input())
a = np.array(input().split(), np.int32)
S = np.zeros(n + 1, np.int32)
S[1:] = np.cumsum(a)

cnt = Counter(S)
ans = 0
for x in cnt:
    # nCr
    if cnt[x] > 1:
        ans += factorial(cnt[x]) // 2 // factorial(cnt[x] - 2)
print(ans)