#include using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define INF 9999999999999999 #define rep(i,m,n) for(ll i = m;i < n;i++) #define rrep(i,m,n) for(ll i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(50) << S << endl #define Vec(K,L,N,S) vector K(N,S) #define DV(K,L,N,M,S) vector> K(N,vector(M,S)) #define TV(K,L,N,M,R,S) vector>> K(N,vector>(M,vector(R,S))) #define pint pair #define tint tuple #define mod 998244353 #define MAX 100010 #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) int main() { ll N; cin >> N; vector A(N), B(N); rep(i, 0, N) cin >> A[i]; rep(i, 0, N) cin >> B[i]; Sort(A); multimap mp; mp.insert(pint(0, 0)); ll res = 0; rep(i, 0, N) { mp.insert(pint(B[i], 0)); auto itr = mp.lower_bound(A[i]); itr--; //res += distance(mp.begin(), itr); //cout << *itr << " " << res << endl; } cout << res << endl; }