#include #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; using LL = long long; int main(){ int N; cin >> N; vector a(N), b(N); rep(i,N) cin >> a[i]; rep(i,N) cin >> b[i]; sort(a.begin(),a.end()); vector c; LL ans=0; rep(i,N){ c.emplace_back(b[i]); sort(c.begin(),c.end()); LL res=lower_bound(c.begin(),c.end(),a[i])-c.begin(); ans+=res; } cout << ans << endl; return 0; }