#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } vector s = {a[0], b[0], (a[0] + b[0]) / 2}; vector> val(3, vector(2)); val[0][0] = val[0][1] = a[0]; val[1][0] = val[1][1] = b[0]; val[2][0] = val[2][1] = (a[0] + b[0]) / 2; for (int i = 1; i < n; i++) { for (int j = 0; j < 3; j++) { int x = abs(a[i] - s[j]); int y = abs(b[i] - s[j]); int z = abs((a[i] + b[i]) / 2 - s[j]); if (min({x, y, z}) == x) { val[j][0] = min(val[j][0], a[i]); val[j][1] = max(val[j][1], a[i]); } else if (min({x, y, z}) == y) { val[j][0] = min(val[j][0], b[i]); val[j][1] = max(val[j][1], b[i]); } else { val[j][0] = min(val[j][0], (a[i] + b[i]) / 2); val[j][1] = max(val[j][1], (a[i] + b[i]) / 2); } } } int ans = min({val[0][1] - val[0][0], val[1][1] - val[1][0], val[2][1] - val[2][0]}); cout << ans << '\n'; }