#include #include using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.14159265359; ll inf=1001000000000; ll mod=1000000007; int main(){ ll n; cin >> n; vectora(n),b(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } for (ll i = 0; i < n; i++) { cin >> b[i]; } if (n==1) { cout <<0 << endl; return 0; } ll left=0,right=inf; ll ans=inf; while (right-left>1) { ll mid=(right+left)/2; bool ok=true; vectorx; for (ll i = 0; i < n; i++) { vectorc; if (a[i]>=mid) { c.push_back(a[i]); } if (b[i]>=mid) { c.push_back(b[i]); } if ((a[i]+b[i])/2>=mid) { c.push_back((a[i]+b[i])/2); } if (c.empty()) { ok=false; break; } sort(c.begin(),c.end()); x.push_back(c[0]); } if (!ok) { right=mid; continue; }else{ left=mid; } sort(x.begin(),x.end()); if (x[x.size()-1]-x[0]