Increase count of prefix sum .
if ( map . ContainsKey ( prefix_sum [ i ] ) ) map . Add ( prefix_sum [ i ] , map [ prefix_sum [ i ] ] + 1 ) ; else map . Add ( prefix_sum [ i ] , 1 ) ; } return sum ; } sum = 0 ;