#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; N *= 2; vector A(N),B(N); for(auto &a : A) cin >> a; for(auto &b : B) cin >> b; vector already(N); long long answer = 0; for(int i=0; i A.at(k)+B.at(k)) now = A.at(k)+B.at(k),pos = k; } already.at(pos) = true; answer += A.at(pos); now = 1e18; for(int k=0; k A.at(k)+B.at(k)) now = A.at(k)+B.at(k),pos = k; } already.at(pos) = true; answer -= B.at(pos); } cout << answer << endl; }