def max_times(t)
	_a = $a.dup
	if _a.max == _a[t]
		_a.delete_at(t)
		puts _a.max
    	else 
      		puts _a.max
    	end
end


n = gets.to_i
$a = n.times.map{gets.to_i}

n.times do |i|
	max_times(i)
end
