#include <bits/stdc++.h>   #define int long long   #define INF (1e15 + 7)   #define pii pair<int, int>      using namespace std;      struct Node {       int x, y;       Node(int _x = 0, int _y = 0) : x(_x), y(_y) {}       bool operator<(const Node &u)const {           if (x < u.x) return true;           if (x > u.x) return false;           return y > u.y;       }   };      const int MAX_N = 2e5 + 7;   Node in[MAX_N], de[MAX_N];   vector<pii> ab, ba;   int a[MAX_N], b[MAX_N];   int n, mx, dis, top;      inline int low_bound(vector<pii> &s, int x) {       while (top && s[top - 1].first > x) {           --top;       }       if (!top) return -1;       return s[top - 1].second;   }         signed main() {       // freopen( in.txt ,  r , stdin);       scanf( %lld , &n);       for (int i = 1; i <= n; ++i) scanf( %lld , a + i);       for (int i = 1; i <= n; ++i) scanf( %lld , b + i);       int n1 = 0, n2 = 0;       for (int i = 1; i <= n; ++i) {           if (a[i] < b[i]) in[++n1] = Node(a[i], b[i]);           else if (a[i] > b[i]) de[++n2] = Node(b[i], a[i]);           dis += abs(a[i] - b[i]);       }       sort(in + 1, in + 1 + n1);       sort(de + 1, de + 1 + n2);       int len1 = 0, len2 = 0;       for (int i = 1; i <= n1; ++i) {           if (!len1 || in[i].y > ab[len1 - 1].second) {               ab.push_back(pii(in[i].x, in[i].y));               ++len1;           }       }       for (int i = 1; i <= n2; ++i) {           if (!len2 || de[i].y > ba[len2 -1].second) {               ba.push_back(pii(de[i].x, de[i].y));               ++len2;           }       }       top = len2;       for (int i = len1 - 1; i >= 0; --i) {           int y = low_bound(ba, ab[i].first);           if (~y) mx = max(mx, min(y, ab[i].second) - ab[i].first);       }       top = len1;       for (int i = len2 - 1; i >= 0; --i) {           int y = low_bound(ab, ba[i].first);           if (~y) mx = max(mx, min(y, ba[i].second) - ba[i].first);       }       printf( %lld n , dis - mx * 2);       return 0;   }