Stores the suffix sums
let suffix_sum = Array . from ( { length : n } , ( _ , i ) => 0 ) ; suffix_sum [ n - 1 ] = arr [ n - 1 ] ; for ( let i = n - 2 ; i >= 0 ; i -- ) suffix_sum [ i ] = suffix_sum [ i + 1 ] + arr [ i ] ; let s = 1 , e = 1 ; let curr_subarray_sum = 0 , count = 0 ;