from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))

ruiseki = [0]
for ai in a:
    ruiseki.append(ruiseki[-1] + ai)

d = defaultdict(lambda:0)
for ri in ruiseki:
    d[ri] += 1

MOD = 10**9 + 7
def comb_fermat(n:int, r:int)->int:
    # Fermat's little theorem: O(r)
    # return nCr (mod MOD)
    if r > n: return 0
    if r > n-r: return comb_fermat(n, n-r)
    mul,div = 1,1
    for i in range(r):
        mul *= n-i
        mul %= MOD
        div *= i+1
        div %= MOD

    ret = mul * pow(div, MOD-2, MOD) % MOD
    return ret

ans = 0
for k in d.keys():
    ans += comb_fermat(d[k], 2)
print(ans)
