min cost to convert ary into sorted without re-arrange