swap with tail of array