// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define patkan 9
#define tisic 47
#define soclose 1e-9
#define pi 3.1415926535898
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):(x))
#define uint unsigned int
#include <time.h>
// mylittlepony
using namespace std;
int main() {
cin.sync_with_stdio(0);
int N;
cin >> N;
vector<long long> R(N),S(N);
for(int i =0; i < N; i++) cin >> R[i];
for(int i =0; i < N; i++) cin >> S[i];
vector< pair<long long,long long> > A(2*N);
for(int i =0; i < N/2; i++) A[i].ff =R[i]-(N/2-i), A[i].ss =R[i];
for(int i =N/2; i < N; i++) A[i].ff =R[i]-(i-N/2), A[i].ss =R[i];
for(int i =0; i < N/2; i++) A[i+N].ff =S[i]-(N/2-i), A[i+N].ss =S[i];
for(int i =N/2; i < N; i++) A[i+N].ff =S[i]-(i-N/2), A[i+N].ss =S[i];
sort(A.begin(),A.end());
if(A[N].ff > 0) {
long long x =A[N].ff;
for(int i =0; i < 2*N; i++) A[i].ff -=x;}
long long x =0;
for(int i =0; i < 2*N; i++) x =max(x,A[i].ff-A[i].ss);
for(int i =0; i < 2*N; i++) A[i].ff -=x;
long long ans =0;
for(int i =0; i < 2*N; i++) ans +=abs(A[i].ff);
cout << ans << "\n";
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPH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