n=gets.to_i
$as=gets.split.map(&:to_i)
#p $as
def solve(left,rs)
    return [] if rs==[];
    rs.each{|x|
        if x != $as[left-1]
            #print left,"->",x,"?\n"
            ret = solve(x,rs-[x])
            if ret != nil
                #p ret
                return [x]+ret
            end
        end
    }
    return nil
end

r = solve(1,(2..n).to_a)

if r != nil
    print [1,*r].join(" ")
else
    print -1
end