This element can be inserted to the right of the previous element , only if it is greater than the previous element and in the range .
if ( arr [ i ] > arr [ i - 1 ] && arr [ i ] > min && arr [ i ] < max ) {