from itertools import permutations def calc(N,A,B): win = 0 al = list(permutations(range(N))) total = len(al) for v in al: for u in al: a = 0 b = 0 for i in v: for j in u: if A[i] > B[j]: a += 1 elif A[i] < B[j]: b += 1 if a > b: win += 1 return win/2*total def main(): N = int(input()) A = list(map(int,input().split(" "))) B = list(map(int,input().split(" "))) print(calc(N,A,B)) if __name__ == '__main__': main()