def accumulate(vec):
    v= [0 for i in range(len(vec)+1)]
    v[0] = 0
    for i in range(1,len(vec)+1):
        v[i] = v[i-1] + vec[i-1]
    return v

def main():
    N = int(input())
    vec = map(int,input().split())

    accum = accumulate(vec)
    accum.sort()

    ans = 0
    cnt = 0
    for i in range(1,N+1):
        if(accum[i-1] == accum[i]):
            cnt += 1
            if(i == N):
                cnt += 1;
                ans += cnt * (cnt-1) / 2
        else:
            cnt += 1
            ans += cnt * (cnt-1) /2
            cnt = 0

    print(ans)

main()
