#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector VI; typedef vector VVI; typedef vector VL; typedef vector VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back int main() { int n;cin>>n; int A[n],B[n-1]; rep(i,n){cin>>A[i];} rep(i,n-1){cin>>B[i];} sort(A,A+n); sort(B,B+n-1); map> ans; LL L[n-1],R[n-1]; rep(i,n-1){L[i]=abs(A[i]-B[i]);} rep(i,n-1){R[i]=abs(A[i+1]-B[i]);} rep(i,n-2){L[i+1]+=L[i];} for(int i=n-3;i>=0;i--){R[i]+=R[i+1];} //rep(i,n-1){cout< D=(it).second; cout<