Matches
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Walk Alone has two rows of matches, each of which contains n matches. He defines the distance between them as d=\sum_{i=1}^n |a_i-b_i|, where a_i and b_i represent the height of the i-th match in the first row and the second row, respectively. Walk Alone wants to beautify the matches by shortening the distance, and you are asked to find out the minimum distance after performing at most one swap within one row. Note that the height can be negative.

输入描述:

The first line contains one integer n\ (1\leq n \leq 10^6), denoting the number of matches in each row.

The second and the third line both contains n integers, representing the height of matches in the first row and the second row, respectively. All of these numbers satisfy |a_i|, |b_i| \leq 10^{9}.

输出描述:

Print one line containing a single integer, the minimum distance you can get.
示例1

输入

复制
3
1 2 3
3 2 1

输出

复制
0
示例2

输入

复制
4
4 3 9 9
7 3 7 3

输出

复制
5

备注:

In the second example, one of the best strategies is to swap a_1 and a_4, and the minimum distance is |9-7|+|3-3|+|9-7|+|4-3|=5.