reduce the times of comparing by making use of the invariant,
since we are expecting that every element on the right of the pivot
is larger than it and a[right] already meets this condition after
median3.