program main
  implicit none

  integer, allocatable, dimension ( : ) :: A, tmp
  integer :: n, i

  read *, n

  allocate ( A ( 1:n ) )
  allocate ( tmp ( 1:n ) )
  
  do i = 1, n
     read *, A ( i )
  end do

  tmp = A
  
  do i = 1, n
     A = tmp
     A ( i ) = 0
     print *, maxval ( A )
  end do

end program main
