Mr. Hikiko will react with a “Not Bad”, if you can solve this problem.
An array is a Not Bad array if the sum of all of its element is equal to its length. For example, this array is a Not Bad array since the sum of all its element is (which is equal to its length).
Given an array. Find the number of non-empty Not Bad sub-arrays of this array.
A sub-array is a contiguous part of an array. For example, consider the array . There are 6 non-empty sub-arrays. The sub-arrays are , , , , , .
The first line will contain (), the length of the array.
The next line will contain the elements of the array ().
Print the number of non-empty Not Bad sub-arrays of given array.
5 1 -1 3 -1 2