def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = [0]*N
    s = 0
    for i in range(N):
        a = A[i]
        s += a
        S[i] = s

    # print(S)
    ans = 0
    if S[0] == 0:
        ans += 1
    for i in range(1, N):
        if S[i] == 0:
            ans += 1
        for j in range(i):
            d = S[i] - S[j]
            if d == 0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()
