#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);
int n;
cin>>n;
vector<long long>a(n);
vector<long long>b(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector<long long>::iterator low;
long long p;
long long sum=0;
for(int i=0;i<n;i++){
low=upper_bound(b.begin(),b.end(),a[i]);///ako su isti sabiram
p=low-b.begin();
sum+=(2*p-n)*a[i];
}
for(int i=0;i<n;i++){
low=upper_bound(a.begin(),a.end(),b[i]-1);///ako su isti oduzimam ih
p=low-a.begin();
sum+=(2*p-n)*b[i];
}
cout<<sum;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKDApOwogICAgaW50IG47CiAgICBjaW4+Pm47CiAgICB2ZWN0b3I8bG9uZyBsb25nPmEobik7CiAgICB2ZWN0b3I8bG9uZyBsb25nPmIobik7CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKWNpbj4+YVtpXTsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspY2luPj5iW2ldOwogICAgc29ydChhLmJlZ2luKCksYS5lbmQoKSk7CiAgICBzb3J0KGIuYmVnaW4oKSxiLmVuZCgpKTsKICAgIHZlY3Rvcjxsb25nIGxvbmc+OjppdGVyYXRvciBsb3c7CiAgICBsb25nIGxvbmcgcDsKICAgIGxvbmcgbG9uZyBzdW09MDsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGxvdz11cHBlcl9ib3VuZChiLmJlZ2luKCksYi5lbmQoKSxhW2ldKTsvLy9ha28gc3UgaXN0aSBzYWJpcmFtCiAgICAgICAgcD1sb3ctYi5iZWdpbigpOwogICAgICAgIHN1bSs9KDIqcC1uKSphW2ldOwoKICAgIH0KICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGxvdz11cHBlcl9ib3VuZChhLmJlZ2luKCksYS5lbmQoKSxiW2ldLTEpOy8vL2FrbyBzdSBpc3RpIG9kdXppbWFtIGloCiAgICAgICAgcD1sb3ctYS5iZWdpbigpOwogICAgICAgIHN1bSs9KDIqcC1uKSpiW2ldOwogICAgfQogICAgY291dDw8c3VtOwogICAgcmV0dXJuIDA7Cn0=