l = 1 r = n do while (lj) exit end do if (j