#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;
int i,j;
int a[10001];
int b[10001];
int p[10001];
int n;
int f[10001][2];
void tr(int x,int y)
{
if (abs(a[x]-b[y])<p[x])
{
p[x]=abs(a[x]-b[y]);
if (y!=n-1) tr(x,y+1);
}
else
{
if (x!=n) tr(x+1,y);
}
}
int main()
{
freopen("parellel.in","r",stdin);
freopen("parellel.out","w",stdout);
scanf("%d",&n);
while (n!=0)
{
for (i=1;i<=n;i++) scanf("%d",&a[i]);
for (i=1;i<=n-1;i++) scanf("%d",&b[i]);
sort(a+1,a+n+1);
sort(b+1,b+n);
for (i=1;i<=n;i++) p[i]=99999999;
tr(1,1);
f[1][0]=abs(a[1]-b[1]);
f[1][1]=0;
for (i=1;i<=n;i++)
{
f[i][0]=f[i-1][0]+abs(a[i]-b[i]);
f[i][1]=min((f[i-1][1]+abs(a[i]-b[i-1])),(f[i-1][0]+p[i]));
}
printf("%d\n",f[n][1]);
scanf("%d",&n);
}
}