<?php
for ($i = 0; $i < $q; $i++){
for ($j = 0; $j < ($q-1); $j++){
$J = $a[$j];
if ($a[$j]>$a[$j+1]){
$a[$j] = $a[$j+1];
$a[$j+1] = $J;
}
}
}
PD9waHAKJGEgPSBhcnJheSg0LDEsMywyLDUpOwokcSA9IGNvdW50KCRhKTsKZm9yICgkaSA9IDA7ICRpIDwgJHE7ICRpKyspewoJZm9yICgkaiA9IDA7ICRqIDwgKCRxLTEpOyAkaisrKXsKCQkkSiA9ICRhWyRqXTsKCQlpZiAoJGFbJGpdPiRhWyRqKzFdKXsKCQkJJGFbJGpdID0gJGFbJGorMV07CgkJCSRhWyRqKzFdID0gJEo7CgkJfQoJfQp9CnByaW50X3IoJGEpOw==