The "absolute sum" of an array is defined as the absolute value or the modulus of the sum of its elements. For example, the array [4,-5,-6) has an absolute sum of while the array [5,-4] has an absolute sum of 1. Let us define the "beauty" of an array as the minimum of the absolute sums of all its subarray. A "subarray" is defined as a non-empty sequence of consecutive elements of the array. An array is "beautiful" If It has a beauty greater than zero. For example, the array [-4,5,7] is beautiful with a positive beauty of 1, as its non-empty subarrays [-4], [5], [7), [-4,5]. [5,7], [-4,5,7] have absolute sums of 4, 5, 7, 1, 12 and 8 respectively On the other hand, the array [-1,1,3] is not beautiful as has a beauty of O because of its subarray (-1,1].
Given an arr of length n, find its number of subarrays which are beautiful.
n<=10^5