Replace every element by smallest of all other elements
for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] != firstSmallest ) : NEW_LINE INDENT arr [ i ] = firstSmallest NEW_LINE DEDENT else : NEW_LINE INDENT arr [ i ] = secondSmallest NEW_LINE DEDENT DEDENT