N,*A=$<.map &:to_i p *(0..99).map{[*0...N].shuffle}.find{|b|i=-1;b.all?{_1!=A[i+=1]}}||-1