Subtract same count after end index
count_Arr [ end + 1 ] -= factor * N ; NEW_LINE factor += 1 ; NEW_LINE size //= 2 ; NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE count_Arr [ i ] += count_Arr [ i - 1 ] ; NEW_LINE