changed here as in case of even elements there will be 2 medians
median2 = arr [ ( ( n * m ) // 2 ) - 1 ] NEW_LINE minOperations2 = 0 NEW_LINE for i in range ( n * m ) : NEW_LINE INDENT minOperations2 += abs ( arr [ i ] - median2 ) / k NEW_LINE DEDENT minOperations = min ( minOperations , minOperations2 ) NEW_LINE