def get(list,value,count,num):
    if len(list) == 0:
        return count
    value += list[0]
    if value == 0 and num != 0:
        count += 1
    list = list[1:]
    return get(list,value,count,num+1)

size = int(input())
list_input = input().split()
list_input = [int(s) for s in list_input]

count = 0
for i in range(size):
    count += get(list_input[i:],0,0,0)
    
print(count)