#include #include using namespace std; int N; int A[2<<17][3]; int id[2<<17]; int main() { cin>>N; for(int i=0;i>A[i][0]; for(int i=0;i>A[i][1]; set >S; for(int i=0;ib)swap(a,b); A[i][0]=a; A[i][1]=(a+b)/2; A[i][2]=b; S.insert(make_pair(a,i)); } int ans=S.rbegin()->first-S.begin()->first; while(true) { pairp=*S.begin(); S.erase(S.begin()); int i=p.second; if(id[i]==2)break; id[i]++; S.insert(make_pair(A[i][id[i]],i)); ans=min(ans,S.rbegin()->first-S.begin()->first); } cout<