Question
Swap & Maximize

In a math challenge, Vikram was given two arrays, A and B, each containing N elements. His task was to maximize the difference between the sum of elements in array A (sumA) and the sum of elements in array B (sumB). The twist was that in each move, Vikram could swap any element from array A with any element from array B - they didn’t have to be at the same index. Now, Vikram must figure out the optimal way to maximize the value of sumA - sumB using these swaps. Can you help Vikram solve this puzzle?

Input
The first line of the input contains an integer N.
The second line of the input contains N space-separated integers of array A.
The third line of the input contains N space-separated integers of array B.

Constraints
1 ≤ N ≤ 105
1 ≤ Ai, Bi ≤ 109
Output
Print the maximum possible value of sumA - sumB possible after apply optimal moves.
Example
Sample Input
5
7 9 4 4 2
8 3 2 4 1
Sample Output
20
Explanation
We swap B1 with A5, This makes A = [7, 9, 4, 4, 8], B = [2, 3, 2, 4, 1]. sumA = 32.
sumB = 12.
sumA - sumB = 20
It can be proved that this is the maximum possible difference.

Online