Increase count of prefix sum .
if ( m . containsKey ( prefix_sum [ i ] ) ) m . put ( prefix_sum [ i ] , m . get ( prefix_sum [ i ] ) + 1 ) ; else m . put ( prefix_sum [ i ] , 1 ) ; } return sum ; } sum = 0 ;