# coding: utf-8
# Your code here!
num = input().rstrip()
#print(num)

line = input().rstrip().split(" ")
#print(line)

count = 0

att = 0
# num数まで一つ一つ見ていく0になった時点でカウント\
for i in range(int(num)):
    att = int(line[i])
    #print(i)
    for j in range(i+1,int(num)):
        att += int(line[j])
        #print(str(i) + "," + str(j) + "," + str(att))
        if att == 0:
            count += 1

print(count)