n = gets.to_i a = gets.split b = gets.split aa = a.permutation(n).to_a p aa aaa = aa.zip(b).map {|i| (i[0] > i[1]) ? (i[0] - i[1]) : 0 } p aaa