

def binary_insert(array, target)
  head = 0
  tail = array.count - 1
  while (head <= tail) do
    center = (head + tail) / 2
    if ( (array[center] == target) )
      return center
    elsif ( head == center)
      if(array[head] < target)
        return head
      else
        return (head+1)
      end
    elsif array[center] < target
      head = center + 1
    else
      tail = center - 1
    end
  end
end



n = gets.chomp.to_i
#puts "n = #{n}"
a = []
moto_a = []
n.times do|i|
  #puts "hello"
  if(i == 0) then
    a << gets.chomp.to_i
    moto_a << a[0]
  else
    t = gets.chomp.to_i
    moto_a << t
    #pp "now a = #{a}"
    a.insert(binary_insert(a, t) , t)
    #pp "then a = #{a}"
  end
end


n.times do|i|
  if (moto_a[i] == a[0]) 
    puts a[1]
  else 
    puts a[0]
  end
end