Insert it again into the multiset since it is within the k - size window
s . append ( [ p [ i ] , dp [ i ] ] ) ; NEW_LINE s . sort ( ) NEW_LINE for i in range ( k , n ) : NEW_LINE l = s [ 0 ] [ 0 ] NEW_LINE min = s [ 0 ] [ 1 ] NEW_LINE p [ i ] = math . log ( arr [ i ] ) + l ; NEW_LINE dp [ i ] = ( arr [ i ] * min ) % mod ; NEW_LINE