#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; template struct SWAG{ using F=function; const F f; stack stl, str, str2; SWAG(const F f): f(f){} bool empty(){ if(stl.empty() && str.empty()) return true; return false; } void push(const T &x){ if(str.empty()) str.push(x); else str.push(f(str.top(), x)); str2.push(x); } void pop(){ assert(!empty()); if(stl.empty()){ while(!str2.empty()){ if(stl.empty()) stl.push(str2.top()); else stl.push(f(str2.top(), stl.top())); str2.pop(); str.pop(); } } stl.pop(); } T get(){ assert(!empty()); if(stl.empty()) return str.top(); else if(str.empty()) return stl.top(); else return f(stl.top(), str.top()); } }; ll gcd(ll a, ll b){ if(a==0) return b; if(b==0) return a; if(a<0) a=-a; if(b<0) b=-b; const int s=__builtin_ctzll(a|b); a>>=__builtin_ctzll(a); while(b){ b>>=__builtin_ctzll(b); if(a>b) swap(a, b); b-=a; } return a< a(n); for(int i=0; i seg([&](ll x, ll y){ return gcd(x, y);}); ll ans=0; int r=-1; for(int i=0; i