Increase count of prefix sum .
if ( mp . ContainsKey ( prefix_sum [ i ] ) ) mp . Add ( prefix_sum [ i ] , mp [ prefix_sum [ i ] ] + 1 ) ; else mp . Add ( prefix_sum [ i ] , 1 ) ; } return sum ; } if ( k == - 1 ) { sum = 0 ; Dictionary < long , int > map = new Dictionary < long , int > ( ) ; for ( int i = n ; i >= 0 ; i -- ) {