program main
  implicit none
  integer::n,i,p,q,tmp
  integer,allocatable::a(:)

  read *,n
  allocate(a(0:n-1))
  read *,a(0:n-1)

  do i=1,2*n-4
     do p=0, n-1
        q = i-p
        if(q.lt.0.or.q.ge.n.or.p.ge.q) cycle
        if(a(p).gt.a(q)) then
           tmp  = a(p)
           a(p) = a(q)
           a(q) = tmp
        end if
!        print *,i,p,q
!        call aprinter(a)
     end do
  end do
  call aprinter(a)
contains
  subroutine aprinter(array)
    integer*4::array(:)
    character*32::cformat='(i0,     (1x,i0))'
    write(cformat(5:9),'(i0)'),size(array)
    write(*,cformat) array
  end subroutine aprinter
end program main