#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int N;
int answer = 0;
vector<int> a, b;
cin>>N;
for(int i=0;i<N;i++){
int number;
cin>>number;
a.push_back(number);
}
for(int i=0;i<N;i++){
int number;
cin>>number;
b.push_back(number);
}
sort(a.begin(), a.end(), greater<int>());
sort(b.begin(), b.end());
for(int i=0;i<N;i++){
answer += a[i]*b[i];
}
cout<<answer<<'\n';
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgljaW4udGllKDApOwoJY291dC50aWUoMCk7Cglpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKCQoJaW50IE47CglpbnQgYW5zd2VyID0gMDsKCXZlY3RvcjxpbnQ+IGEsIGI7CgkKCWNpbj4+TjsKCWZvcihpbnQgaT0wO2k8TjtpKyspewoJCWludCBudW1iZXI7CgkJY2luPj5udW1iZXI7CgkJYS5wdXNoX2JhY2sobnVtYmVyKTsKCX0KCWZvcihpbnQgaT0wO2k8TjtpKyspewoJCWludCBudW1iZXI7CgkJY2luPj5udW1iZXI7CgkJYi5wdXNoX2JhY2sobnVtYmVyKTsKCX0KCXNvcnQoYS5iZWdpbigpLCBhLmVuZCgpLCBncmVhdGVyPGludD4oKSk7Cglzb3J0KGIuYmVnaW4oKSwgYi5lbmQoKSk7CgkKCWZvcihpbnQgaT0wO2k8TjtpKyspewoJCWFuc3dlciArPSBhW2ldKmJbaV07Cgl9Cgljb3V0PDxhbnN3ZXI8PCdcbic7CgkKCXJldHVybiAwOwp9