import numpy
N = int(input())
ary = list(map(int, input().split(' ')))
ary_int = numpy.cumsum(ary)
ary_int_rev = numpy.cumsum(ary[::-1])
diff = (ary_int - ary_int_rev[::-1]).tolist()
ary_int = ary_int.tolist()
ary_int_rev = ary_int_rev.tolist()
count = 0
count += ary_int[:N-1].count(0) + ary_int_rev[:N-1].count(0) + diff[:N-1].count(0)
print(count)