I have misunderstanding about math operation of finding element (max, min) and further manipulations with them (replacement other elements with them, adding to the end / beginni