N = gets.to_i A = gets.split.map(&:to_i) B = gets.split.map(&:to_i) p = (1..N).inject(:*) ans = A.permutation.to_a.product(B.permutation.to_a).count {|a, b| a.zip(b).count {|x, y| x > y} > N / 2}.fdiv(p**2) puts ans