import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) class BIT: def __init__(self,init_value): self.n = len(init_value) self.tree = [0]*(self.n+1) for i in range(1,self.n+1): x = init_value[i-1] while i <= self.n: self.tree[i] += x i += i & (-i) def update(self,i,x): # i(1-index)番目の値を+x while i <= self.n: self.tree[i] += x i += i & (-i) return def query(self,i): # 1番目からi(1-index)番目までの和を返す res = 0 while i > 0: res += self.tree[i] i -= i & (-i) return res N = I() A,B = LI(),LI() A.sort() # 座標圧縮 X = list(set(A+B)) X.sort() M = len(X) d = {} for i in range(1,M+1): d[X[i-1]] = i bit = BIT([0]*200001) ans = 0 for i in range(N): a = A[i] b = B[i] bit.update(d[b],1) ans += bit.query(d[a]-1) print(ans)