debug=True def pprint(*s): if debug==True: print(*s) class BIT: def __init__(self,n): self.n=n+1 self.BIT=[0]*self.n def add(self,i,x): idx=i while idx0: ret+=self.BIT[idx] idx-=(idx&-idx) return ret def sum(self,l,r): return self._sum(r)-self._sum(l-1) def value(self,i): return self._sum(i)-self._sum(i-1) n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) a=sorted(a) tmp=sorted(list(set(a)|set(b))) dic={} for i in range(len(tmp)): dic[tmp[i]]=i+1 bit=BIT(len(tmp)) ans=0 for i in range(n): bit.add(dic[b[i]],1) ans+=bit.sum(1,dic[a[i]]-1) print(ans)