def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    
#    print(A)
    result = 0
    s = [A[0]]
    for i in range(1, N):
        s.append(s[i - 1] + A[i])
#    print(s)
    
    for i in range(N):
        if(s[i] == 0):
            result += 1
        for j in range(i):
#            print(s[i] - s[j])
            if((s[i] - s[j]) == 0):
                result += 1
                
#    for nc_len in range(1, N + 1):
#        for i in range(N - nc_len + 1):
##            print(A[i : i + nc_len])
#            if(sum(A[i : i + nc_len]) == 0):
#                result += 1
    
    print(result)
    
if __name__=="__main__":
    main()