#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>


using namespace std;

pair<int, int> p[200005];
vector<int> query[200005];

int find(int v, int n) {
    int low = 0, high = n - 1;
    int ans = -1;
    while (low <= high) {
        int mid = (low + high) >> 1;
        if (p[mid].first <= v) {
            ans = mid;
            low = mid + 1;
        } else  high = mid - 1;
    }
    return  ans;
}

long long int solve(int n) {
    long long int tot = 0;
    long long int res = 0;
    for (int i = 0;i < n;i++) {
        tot += abs(p[i].first - p[i].second);
        if (p[i].first >= p[i].second) {
            int pos = find(p[i].second, n);
            if (pos != -1) {
                query[pos].emplace_back(i);
            }
        }
    }
    set<int> st;
    for (int i = 0;i < n;i++) {
        if (p[i].first <= p[i].second)
            st.insert(p[i].second);
        for (auto x : query[i]) {
            auto it = st.upper_bound(p[x].first);
            if (!st.empty() && it != st.begin()) {
                it--;
                res = max(res, 2ll * (*it - p[x].second));
            }
            if (!st.empty() && *st.rbegin() >= p[x].first) {
                res = max(res, 2ll * (p[x].first - p[x].second));
            }
        }
    }
    for (int i = 0;i < n;i++) query[i].clear();
    return tot - res;
}

int main(void) {
    int n;
    scanf("%d", &n);
    for (int i = 0;i < n;i++) {
        scanf("%d", &p[i].first);
    }
    for (int i = 0;i < n;i++) {
        scanf("%d", &p[i].second);
    }
    sort(p, p + n);
    long long ans = solve(n);
    for (int i = 0;i < n;i++)swap(p[i].first, p[i].second);
    sort(p, p + n);
    long long ans1 = solve(n);
    printf("%lld\n", min(ans, ans1));
    return 0;
}