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

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

ans = [sum([1 for j in range(i + 1, lenums + 1) if sum(nums[i:j]) == 0]) for i in range(lenums)]
answer = sum(ans)

print(answer)
