n = gets.to_i
numbers = []
n.times do
  numbers << gets.to_i
end

(0...numbers.length).each do |i|
  left, right = numbers.partition{|e| numbers.index(e) == i}
  longer = left
  if right.length > left.length
    longer = right
  end
  puts longer.max
end

