//#define _GLIBCXX_DEBUG #include using namespace std; #define endl '\n' #define lfs cout<= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD1 = 1e9+7; const ll MOD9 = 998244353; const ll INF = 1e18; using P = pair; template bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;} template bool chmax(T1 &a,T2 b){if(a void ans(bool x,T1 y,T2 z){if(x)cout< void debug(vector>&v,ll h,ll w){for(ll i=0;i&v,ll h,ll w){for(ll i=0;i void debug(vector&v,ll n){if(n!=0)cout< vector>vec(ll x, ll y, T w){ vector>v(x,vector(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } template ostream &operator<<(ostream &os, const pair&p){ return os << p.first << " " << p.second; } template struct SWAG{ stack>st_front,st_back; T func(T x, T y){return gcd(x,y);} void push_front(T x){ if(st_front.empty())st_front.emplace(x,x); else st_front.emplace(x,func(x, st_front.top().second)); } void push_back(T x){ if(st_back.empty())st_back.emplace(x,x); else st_back.emplace(x,func(st_back.top().second,x)); } void pop_front(){ if(st_front.empty()){ //assert(!st_back.empty()); vectortmp(st_back.size()); for(ll i=(ll)tmp.size()-1;i>=0;i--){ tmp[i] = st_back.top().first; st_back.pop(); } for(ll i=(((ll)tmp.size()-1)>>1);i>=0;i--)push_front(tmp[i]); for(ll i=(((ll)tmp.size()+1)>>1);itmp(st_front.size()); for(ll i=(ll)tmp.size()-1;i>=0;i--){ tmp[i] = st_front.top().first; st_front.pop(); } for(ll i=(((ll)tmp.size()-1)>>1);i>=0;i--)push_back(tmp[i]); for(ll i=(((ll)tmp.size()+1)>>1);i>n; vectora(n); rep(i,0,n)cin>>a[i]; SWAGswag; ll now=0; rep(i,0,n){ while(now