da9ceac45968a9361b8c1f426841c180e711349f8eaab86255346b3a8b6fd6d2
// https://szkopul.edu.pl/problemset/problem/XJGk8X4KSGw8yuy5EYEy4rSK/site/?key=statement
// OIG XV (1 etap)
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long ilosc_mandatow;
cin >> ilosc_mandatow;
vector<long long> K(ilosc_mandatow);
vector<long long> R(ilosc_mandatow);
for (int i = 0; i < ilosc_mandatow; i++) {
cin >> K[i];
}
for (int i = 0; i < ilosc_mandatow; i++) {
cin >> R[i];
}
sort(K.begin(), K.end());
sort(R.begin(), R.end(), greater<long long>());
long long suma = 0;
for (int i = 0; i < ilosc_mandatow; i++) {
suma += stoll(to_string(K[i]) + to_string(R[i]));
}
cout << suma;
return 0;
}