n = gets.to_i a = (1..n).map { gets.to_i } if a.uniq.size == 1 && a[0] < n puts -1 exit end ans = (0...n).to_a (0...n).each do |i| if a[i] == ans[i] j = (i + 1) % n ans[i], ans[j] = ans[j], ans[i] end end puts ans