#include<bits/stdc++.h>
#define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++)
#define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--)
#define ll long long
#define pii pair<int, int>
#define db double
#define x first
#define y second
#define mkp make_pair
#define sz(a) ((int) (a).size())
#define vi vector<int>
using namespace std;
const int N = 5e5 + 7, inf = 1e9 + 7;
int n, ns, rig;
struct SegmentTree /* TO CHEAT, TO ATTACK! */ { 
	int mx[N << 2];
	void upd(int id) { mx[id] = max(mx[id << 1], mx[id << 1 | 1]); }
	void add(int id, int L, int R, int pos, int x) {
		if(pos > R || L > pos) return; 
		if(L == R) return mx[id] = x, void();
		int mid = (L + R) >> 1;
		add(id << 1, L, mid, pos, x), add(id << 1 | 1, mid + 1, R, pos, x), upd(id);
	}
	int qry(int id, int L, int R, int l, int r) {
		if(l > R || L > r) return 0;
		if(l <= L && R <= r) return mx[id];
		int mid = (L + R) >> 1; 
		return max(qry(id << 1, L, mid, l, r), qry(id << 1 | 1, mid + 1, R, l, r));
	}
} t1, t2, t3;
ll all;
pii a[N];
vi q[N];
int rmain() {
	cin >> n;
	L(i, 1, n) cin >> a[i].x;
	L(i, 1, n) cin >> a[i].y, all += abs(a[i].x - a[i].y);
	sort(a + 1, a + n + 1);
	L(i, 1, n) {
		for(int v : q[i]) t2.add(1, 1, n, v, 0), t3.add(1, 1, n, v, a[v].y - a[v].x);
		int p = lower_bound(a + 1, a + n + 1, mkp(a[i].y, -1)) - a;
		if(a[i].y >= a[i].x) 
			q[max(p, i + 1)].push_back(i), 
			t1.add(1, 1, n, i, a[i].y), t2.add(1, 1, n, i, inf - a[i].x);
		else 
			ns = max(ns, min(t1.qry(1, 1, n, 1, p - 1), a[i].x) - a[i].y), 
			ns = max(ns, a[i].x - inf + t2.qry(1, 1, n, p, i)), 
			ns = max(ns, t3.qry(1, 1, n, p, i));
	}
	// cout << ns << "\n";
	cout << all - ns * 2 << "\n";
	return 0;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	rmain();
	return 0;
} 