from bisect import bisect_left N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() t0 = [] t1 = [] result = 0 for i in range(N): c = a[i] t1.append(b[i]) result += bisect_left(t0, c) result += sum(1 for b in t1 if b < c) if len(t1) == 1000: t0.extend(t1) t0.sort() t1 = [] print(result)