class Binary_Indexed_Tree: def __init__(self, n) -> None: self._n = n self.data = [0] * (n+1) self.depth = n.bit_length() def add(self, p, x) -> None: """任意の要素ai←ai+xを行う O(logn)""" assert 0 <= p < self._n p += 1 while p <= self._n: self.data[p-1] += x p += p & (-p) def sum(self, l, r) -> int: """区間[l,r)で計算""" assert 0 <= l <= r <= self._n return self._sum(r) - self._sum(l) def _sum(self, d) -> int: sm = 0 while d > 0: sm += self.data[d-1] d -= d & (-d) return sm N = int(input()) a = list(map(int, input().split())) a.sort() b = list(map(int,input().split())) x_dic = {num:i for i, num in enumerate(list(sorted(set(a+b))))} res = 0 BIT = Binary_Indexed_Tree(len(x_dic)+5) for i in range(N): BIT.add(x_dic[b[i]],1) res += BIT._sum(x_dic[a[i]]) print(res)