#include #include #include #include using namespace std; using namespace atcoder; using ll=long long; ll op(ll a,ll b){ if(a>1001001001001001001 || b>1001001001001001001){ return max(a,b); } return a+b; } ll e() {return 0LL;} ll mapping(ll F,ll x) { if(F>1001001001001001001 || x>1001001001001001001){ return max(F,x); } return F+x; } ll composition(ll F,ll G) { if(F>1001001001001001001 || G>1001001001001001001){ return max(F,G); } return F+G; } ll id(){ return 0LL;} int main(){ ll n,dx=1501001,ans=0; cin>>n; vector a(n),b(n); lazy_segtree s(3001002); for(int i=0;i>a[i];a[i]+=dx;} for(int i=0;i>b[i]; for(int i=0;i csum={s.get(0)}; ll fmin=1001001001001; ll minx; for(ll i=0;i<3001001;i++){ csum.push_back(csum[i]+s.get(i+1)); ll f=csum[i+1]; if(f