N = gets.to_i A = N.times.map { gets.to_i } counter = Hash.new(0) if A.uniq.size == 1 puts -1 exit end A.each do |a| counter[a] += 1 end nums = [*0...N].sort_by { |i| -counter[i] } ans = Array.new(N, -1) nums.each do |n| N.times do |i| next if ans[i] != -1 ans[i] = n break end end puts ans