I have a question, could you please answer it?
You are given two sequences $$$(p_1, p_2, \ldots, p_N)$$$, $$$(q_1, q_2, \dots, q_N)$$$ of length $$$N$$$. What is the value of this sum?
$$$$$$\sum_{i=1}^{N} {\sum_{j=1}^{N} {\min(|p_i - p_j|, |q_i - q_j|)} }$$$$$$
In the first line, a single integer $$$N$$$ is given ($$$ 1 \leq N \leq 1\,000\,000$$$).
In the second line, $$$N$$$ integers $$$p_1, p_2, \ldots, p_N$$$ are given ($$$1 \leq p_i \leq 1\,000\,000$$$).
In the third line, $$$N$$$ integers $$$q_1, q_2, \ldots, q_N$$$ are given ($$$1 \leq q_i \leq 1\,000\,000$$$).
Output a single integer, the answer to the question.
3 1 3 2 1 2 3
6
4 1 1 1000000 1000000 1000000 1000000 1 1
7999992