- Time limit: 1.00 s
- Memory limit: 512 MB
Given two arrays of integers, your task is to permute the arrays so that the sum of pairwise differences is minimum.
Input
The first input line contains an integer .
The second line has integers : the numbers in the first array.
The third line has integers : the numbers in the second array.
Output
Print one integer: the minimum sum of pairwise differences.
Constraints
Example
Input:
3 1 3 5 2 7 8
Output:
8
Explanation: An optimal solution is and . In this solution the sum is .