#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<int>a(n),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());
int ans=0;
for(int i=0;i<n;i++){
ans+= a[i]*b[n-i-1];
}
cout<<ans<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKXsKICAgIGludCBuO2Npbj4+bjsKICAgIHZlY3RvcjxpbnQ+YShuKSxiKG4pOwogICAgZm9yKGludCBpPTA7aTxuO2krKyljaW4+PmFbaV07CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKWNpbj4+YltpXTsKICAgIHNvcnQoYS5iZWdpbigpLGEuZW5kKCkpOwogICAgc29ydChiLmJlZ2luKCksYi5lbmQoKSk7CiAgICBpbnQgYW5zPTA7CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKXsKICAgICAgICBhbnMrPSBhW2ldKmJbbi1pLTFdOwogICAgfQogICAgY291dDw8YW5zPDxlbmRsOwp9