# -*- coding: utf-8 -*-

def main():
	N = int(input())
	A = list(map(int,input().split()))
	c = 0
	for i in range(1,N+1):
		for j in range(0,N-i+1):
			part_A = A[j:j+i]
			if sum(part_A) == 0:
				c += 1
	print(c)

if __name__ == '__main__':
    main()
