Spaces:
Sleeping
Sleeping
Eugene likes working with arrays. And today he needs your help in solving one challenging task.An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.Let's call a nonempty array good if for every nonempty subarray of this array, sum of the elements of this subarray is nonzero. For example, array [β1,2,β3] is good, as all arrays [β1], [β1,2], [β1,2,β3], [2], [2,β3], [β3] have nonzero sums of elements. However, array [β1,2,β1,β3] isn't good, as his subarray [β1,2,β1] has sum of elements equal to 0.Help Eugene to calculate the number of nonempty good subarrays of a given array a. |