#include <bits/stdc++.h>
using i64 = long long;
#ifdef DEBUG
#include "/home/ahmetalp/Desktop/Workplace/debug.h"
#else
#define debug(...) void(23)
#endif
constexpr int inf = int(1E9);
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
std::vector<int> A(2 * N), B(N), C(N);
for (int i = 0; i < 2 * N; ++i) {
std::cin >> A[i];
}
for (int i = 0; i < N; ++i) {
std::cin >> B[i];
}
for (int i = 0; i < N; ++i) {
std::cin >> C[i];
}
std::sort(B.begin(), B.end());
std::sort(C.begin(), C.end());
int ans = inf;
for (int done = 0; done < 2; ++done) {
for (int i = 0; i < N; ++i) {
std::vector<int> b(A.begin(), A.begin() + i);
b.insert(b.end(), A.begin() + i + N, A.end());
std::vector<int> c(A.begin() + i, A.begin() + i + N);
std::sort(b.begin(), b.end());
std::sort(c.begin(), c.end());
int now = 0;
for (int j = 0; j < N; ++j) {
now = std::max(now, std::abs(B[j] - b[j]));
now = std::max(now, std::abs(C[j] - c[j]));
}
ans = std::min(ans, now);
}
std::swap(B, C);
}
std::cout << ans << '\n';
return 0;
}