#include #include #include using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 int main(){ int N; cin>>N; vector a(N),b(N); vector t; rep(i,N){ cin>>a[i]; t.push_back(a[i]); } rep(i,N){ cin>>b[i]; t.push_back(b[i]); } sort(t.begin(),t.end()); t.erase(unique(t.begin(),t.end()),t.end()); rep(i,N){ a[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),a[i])); b[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),b[i])); } sort(a.begin(),a.end()); long long ans = 0LL; fenwick_tree F(t.size()); rep(i,N){ F.add(b[i],1); ans += F.sum(0,a[i]); } cout<