#define PROBLEM "https://yukicoder.me/problems/no/1786"
#include"../../template/template.hpp"//#include"../../segment-tree/rbst-segment-tree.hpp"//usingnamespaceNyaan;intf(inta,intb){returnmax(a,b);}intg(inta,intb){returna+b;}intti(){return-inf;}intei(){return0;}usingSeg=RBSTLazySegmentTree<ll,int,int,f,g,g,ti,ei>;voidNyaan::solve(){inl(N);intpre=0;Segseg;rep(i,N){inl(A);A^=pre;intmx=seg.fold(A,infLL);intsc=max(0,mx+1);seg.apply(0,A,1);seg.apply(A,infLL,-1);seg.set_val(A,sc);llans=seg.min_left_exclusive(infLL,[](intx){returnx<0;},-infLL);out(ans);pre=ans;}}
#line 1 "verify/verify-yuki/yuki-1786.test.cpp"
#define PROBLEM "https://yukicoder.me/problems/no/1786"
#line 2 "template/template.hpp"
usingnamespacestd;// intrinstic#include<immintrin.h>#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cfenv>
#include<cfloat>
#include<chrono>
#include<cinttypes>
#include<climits>
#include<cmath>
#include<complex>
#include<cstdarg>
#include<cstddef>
#include<cstdint>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<deque>
#include<fstream>
#include<functional>
#include<initializer_list>
#include<iomanip>
#include<ios>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<stack>
#include<streambuf>
#include<string>
#include<tuple>
#include<type_traits>
#include<typeinfo>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>// utility#line 1 "template/util.hpp"
namespaceNyaan{usingll=longlong;usingi64=longlong;usingu64=unsignedlonglong;usingi128=__int128_t;usingu128=__uint128_t;template<typenameT>usingV=vector<T>;template<typenameT>usingVV=vector<vector<T>>;usingvi=vector<int>;usingvl=vector<longlong>;usingvd=V<double>;usingvs=V<string>;usingvvi=vector<vector<int>>;usingvvl=vector<vector<longlong>>;template<typenameT>usingminpq=priority_queue<T,vector<T>,greater<T>>;template<typenameT,typenameU>structP:pair<T,U>{template<typename...Args>P(Args...args):pair<T,U>(args...){}usingpair<T,U>::first;usingpair<T,U>::second;P&operator+=(constP&r){first+=r.first;second+=r.second;return*this;}P&operator-=(constP&r){first-=r.first;second-=r.second;return*this;}P&operator*=(constP&r){first*=r.first;second*=r.second;return*this;}template<typenameS>P&operator*=(constS&r){first*=r,second*=r;return*this;}Poperator+(constP&r)const{returnP(*this)+=r;}Poperator-(constP&r)const{returnP(*this)-=r;}Poperator*(constP&r)const{returnP(*this)*=r;}template<typenameS>Poperator*(constS&r)const{returnP(*this)*=r;}Poperator-()const{returnP{-first,-second};}};usingpl=P<ll,ll>;usingpi=P<int,int>;usingvp=V<pl>;constexprintinf=1001001001;constexprlonglonginfLL=4004004004004004004LL;template<typenameT>intsz(constT&t){returnt.size();}template<typenameT,typenameU>inlineboolamin(T&x,Uy){return(y<x)?(x=y,true):false;}template<typenameT,typenameU>inlineboolamax(T&x,Uy){return(x<y)?(x=y,true):false;}template<typenameT>inlineTMax(constvector<T>&v){return*max_element(begin(v),end(v));}template<typenameT>inlineTMin(constvector<T>&v){return*min_element(begin(v),end(v));}template<typenameT>inlinelonglongSum(constvector<T>&v){returnaccumulate(begin(v),end(v),0LL);}template<typenameT>intlb(constvector<T>&v,constT&a){returnlower_bound(begin(v),end(v),a)-begin(v);}template<typenameT>intub(constvector<T>&v,constT&a){returnupper_bound(begin(v),end(v),a)-begin(v);}constexprlonglongTEN(intn){longlongret=1,x=10;for(;n;x*=x,n>>=1)ret*=(n&1?x:1);returnret;}template<typenameT,typenameU>pair<T,U>mkp(constT&t,constU&u){returnmake_pair(t,u);}template<typenameT>vector<T>mkrui(constvector<T>&v,boolrev=false){vector<T>ret(v.size()+1);if(rev){for(inti=int(v.size())-1;i>=0;i--)ret[i]=v[i]+ret[i+1];}else{for(inti=0;i<int(v.size());i++)ret[i+1]=ret[i]+v[i];}returnret;};template<typenameT>vector<T>mkuni(constvector<T>&v){vector<T>ret(v);sort(ret.begin(),ret.end());ret.erase(unique(ret.begin(),ret.end()),ret.end());returnret;}template<typenameF>vector<int>mkord(intN,Ff){vector<int>ord(N);iota(begin(ord),end(ord),0);sort(begin(ord),end(ord),f);returnord;}template<typenameT>vector<int>mkinv(vector<T>&v){intmax_val=*max_element(begin(v),end(v));vector<int>inv(max_val+1,-1);for(inti=0;i<(int)v.size();i++)inv[v[i]]=i;returninv;}vector<int>mkiota(intn){vector<int>ret(n);iota(begin(ret),end(ret),0);returnret;}template<typenameT>Tmkrev(constT&v){Tw{v};reverse(begin(w),end(w));returnw;}template<typenameT>boolnxp(T&v){returnnext_permutation(begin(v),end(v));}// 返り値の型は入力の T に依存// i 要素目 : [0, a[i])template<typenameT>vector<vector<T>>product(constvector<T>&a){vector<vector<T>>ret;vector<T>v;autodfs=[&](autorc,inti)->void{if(i==(int)a.size()){ret.push_back(v);return;}for(intj=0;j<a[i];j++)v.push_back(j),rc(rc,i+1),v.pop_back();};dfs(dfs,0);returnret;}// F : function(void(T&)), mod を取る操作// T : 整数型のときはオーバーフローに注意するtemplate<typenameT>TPower(Ta,longlongn,constT&I,constfunction<void(T&)>&f){Tres=I;for(;n;f(a=a*a),n>>=1){if(n&1)f(res=res*a);}returnres;}// T : 整数型のときはオーバーフローに注意するtemplate<typenameT>TPower(Ta,longlongn,constT&I=T{1}){returnPower(a,n,I,function<void(T&)>{[](T&)->void{}});}template<typenameT>TRev(constT&v){Tres=v;reverse(begin(res),end(res));returnres;}template<typenameT>vector<T>Transpose(constvector<T>&v){usingU=typenameT::value_type;if(v.empty())return{};intH=v.size(),W=v[0].size();vectorres(W,T(H,U{}));for(inti=0;i<H;i++){for(intj=0;j<W;j++){res[j][i]=v[i][j];}}returnres;}template<typenameT>vector<T>Rotate(constvector<T>&v,intclockwise=true){usingU=typenameT::value_type;intH=v.size(),W=v[0].size();vectorres(W,T(H,U{}));for(inti=0;i<H;i++){for(intj=0;j<W;j++){if(clockwise){res[W-1-j][i]=v[i][j];}else{res[j][H-1-i]=v[i][j];}}}returnres;}}// namespace Nyaan#line 58 "template/template.hpp"
// bit operation#line 1 "template/bitop.hpp"
namespaceNyaan{__attribute__((target("popcnt")))inlineintpopcnt(constu64&a){return__builtin_popcountll(a);}inlineintlsb(constu64&a){returna?__builtin_ctzll(a):64;}inlineintctz(constu64&a){returna?__builtin_ctzll(a):64;}inlineintmsb(constu64&a){returna?63-__builtin_clzll(a):-1;}template<typenameT>inlineintgbit(constT&a,inti){return(a>>i)&1;}template<typenameT>inlinevoidsbit(T&a,inti,boolb){if(gbit(a,i)!=b)a^=T(1)<<i;}constexprlonglongPW(intn){return1LL<<n;}constexprlonglongMSK(intn){return(1LL<<n)-1;}}// namespace Nyaan#line 61 "template/template.hpp"
// inout#line 1 "template/inout.hpp"
namespaceNyaan{template<typenameT,typenameU>ostream&operator<<(ostream&os,constpair<T,U>&p){os<<p.first<<" "<<p.second;returnos;}template<typenameT,typenameU>istream&operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;returnis;}template<typenameT>ostream&operator<<(ostream&os,constvector<T>&v){ints=(int)v.size();for(inti=0;i<s;i++)os<<(i?" ":"")<<v[i];returnos;}template<typenameT>istream&operator>>(istream&is,vector<T>&v){for(auto&x:v)is>>x;returnis;}istream&operator>>(istream&is,__int128_t&x){stringS;is>>S;x=0;intflag=0;for(auto&c:S){if(c=='-'){flag=true;continue;}x*=10;x+=c-'0';}if(flag)x=-x;returnis;}istream&operator>>(istream&is,__uint128_t&x){stringS;is>>S;x=0;for(auto&c:S){x*=10;x+=c-'0';}returnis;}ostream&operator<<(ostream&os,__int128_tx){if(x==0)returnos<<0;if(x<0)os<<'-',x=-x;stringS;while(x)S.push_back('0'+x%10),x/=10;reverse(begin(S),end(S));returnos<<S;}ostream&operator<<(ostream&os,__uint128_tx){if(x==0)returnos<<0;stringS;while(x)S.push_back('0'+x%10),x/=10;reverse(begin(S),end(S));returnos<<S;}voidin(){}template<typenameT,class...U>voidin(T&t,U&...u){cin>>t;in(u...);}voidout(){cout<<"\n";}template<typenameT,class...U,charsep=' '>voidout(constT&t,constU&...u){cout<<t;if(sizeof...(u))cout<<sep;out(u...);}structIoSetupNya{IoSetupNya(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);cerr<<fixed<<setprecision(7);}}iosetupnya;}// namespace Nyaan#line 64 "template/template.hpp"
// debug#line 1 "template/debug.hpp"
namespaceDebugImpl{template<typenameU,typename=void>structis_specialize:false_type{};template<typenameU>structis_specialize<U,typenameconditional<false,typenameU::iterator,void>::type>:true_type{};template<typenameU>structis_specialize<U,typenameconditional<false,decltype(U::first),void>::type>:true_type{};template<typenameU>structis_specialize<U,enable_if_t<is_integral<U>::value,void>>:true_type{};voiddump(constchar&t){cerr<<t;}voiddump(conststring&t){cerr<<t;}voiddump(constbool&t){cerr<<(t?"true":"false");}voiddump(__int128_tt){if(t==0)cerr<<0;if(t<0)cerr<<'-',t=-t;stringS;while(t)S.push_back('0'+t%10),t/=10;reverse(begin(S),end(S));cerr<<S;}voiddump(__uint128_tt){if(t==0)cerr<<0;stringS;while(t)S.push_back('0'+t%10),t/=10;reverse(begin(S),end(S));cerr<<S;}template<typenameU,enable_if_t<!is_specialize<U>::value,nullptr_t>=nullptr>voiddump(constU&t){cerr<<t;}template<typenameT>voiddump(constT&t,enable_if_t<is_integral<T>::value>*=nullptr){stringres;if(t==Nyaan::inf)res="inf";ifconstexpr(is_signed<T>::value){if(t==-Nyaan::inf)res="-inf";}ifconstexpr(sizeof(T)==8){if(t==Nyaan::infLL)res="inf";ifconstexpr(is_signed<T>::value){if(t==-Nyaan::infLL)res="-inf";}}if(res.empty())res=to_string(t);cerr<<res;}template<typenameT,typenameU>voiddump(constpair<T,U>&);template<typenameT>voiddump(constpair<T*,int>&);template<typenameT>voiddump(constT&t,enable_if_t<!is_void<typenameT::iterator>::value>*=nullptr){cerr<<"[ ";for(autoit=t.begin();it!=t.end();){dump(*it);cerr<<(++it==t.end()?"":", ");}cerr<<" ]";}template<typenameT,typenameU>voiddump(constpair<T,U>&t){cerr<<"( ";dump(t.first);cerr<<", ";dump(t.second);cerr<<" )";}template<typenameT>voiddump(constpair<T*,int>&t){cerr<<"[ ";for(inti=0;i<t.second;i++){dump(t.first[i]);cerr<<(i==t.second-1?"":", ");}cerr<<" ]";}voidtrace(){cerr<<endl;}template<typenameHead,typename...Tail>voidtrace(Head&&head,Tail&&...tail){cerr<<" ";dump(head);if(sizeof...(tail)!=0)cerr<<",";trace(std::forward<Tail>(tail)...);}}// namespace DebugImpl#ifdef NyaanDebug
#define trc(...) \
do { \
cerr << "## " << #__VA_ARGS__ << " = "; \
DebugImpl::trace(__VA_ARGS__); \
} while (0)
#else
#define trc(...) (void(0))
#endif
#ifdef NyaanLocal
#define trc2(...) \
do { \
cerr << "## " << #__VA_ARGS__ << " = "; \
DebugImpl::trace(__VA_ARGS__); \
} while (0)
#else
#define trc2(...) (void(0))
#endif
#line 67 "template/template.hpp"
// macro#line 1 "template/macro.hpp"
#define each(x, v) for (auto&& x : v)
#define each2(x, y, v) for (auto&& [x, y] : v)
#define all(v) (v).begin(), (v).end()
#define rep(i, N) for (long long i = 0; i < (long long)(N); i++)
#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)
#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)
#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)
#define reg(i, a, b) for (long long i = (a); i < (b); i++)
#define regr(i, a, b) for (long long i = (b)-1; i >= (a); i--)
#define fi first
#define se second
#define ini(...) \
int __VA_ARGS__; \
in(__VA_ARGS__)
#define inl(...) \
long long __VA_ARGS__; \
in(__VA_ARGS__)
#define ins(...) \
string __VA_ARGS__; \
in(__VA_ARGS__)
#define in2(s, t) \
for (int i = 0; i < (int)s.size(); i++) { \
in(s[i], t[i]); \
}
#define in3(s, t, u) \
for (int i = 0; i < (int)s.size(); i++) { \
in(s[i], t[i], u[i]); \
}
#define in4(s, t, u, v) \
for (int i = 0; i < (int)s.size(); i++) { \
in(s[i], t[i], u[i], v[i]); \
}
#define die(...) \
do { \
Nyaan::out(__VA_ARGS__); \
return; \
} while (0)
#line 70 "template/template.hpp"
namespaceNyaan{voidsolve();}intmain(){Nyaan::solve();}#line 4 "verify/verify-yuki/yuki-1786.test.cpp"
//#line 2 "segment-tree/rbst-segment-tree.hpp"
#line 2 "internal/internal-type-traits.hpp"
#line 4 "internal/internal-type-traits.hpp"
usingnamespacestd;namespaceinternal{template<typenameT>usingis_broadly_integral=typenameconditional_t<is_integral_v<T>||is_same_v<T,__int128_t>||is_same_v<T,__uint128_t>,true_type,false_type>::type;template<typenameT>usingis_broadly_signed=typenameconditional_t<is_signed_v<T>||is_same_v<T,__int128_t>,true_type,false_type>::type;template<typenameT>usingis_broadly_unsigned=typenameconditional_t<is_unsigned_v<T>||is_same_v<T,__uint128_t>,true_type,false_type>::type;#define ENABLE_VALUE(x) \
template <typename T> \
constexpr bool x##_v = x<T>::value;
ENABLE_VALUE(is_broadly_integral);ENABLE_VALUE(is_broadly_signed);ENABLE_VALUE(is_broadly_unsigned);#undef ENABLE_VALUE
#define ENABLE_HAS_TYPE(var) \
template <class, class = void> \
struct has_##var : false_type {}; \
template <class T> \
struct has_##var<T, void_t<typename T::var>> : true_type {}; \
template <class T> \
constexpr auto has_##var##_v = has_##var<T>::value;
#define ENABLE_HAS_VAR(var) \
template <class, class = void> \
struct has_##var : false_type {}; \
template <class T> \
struct has_##var<T, void_t<decltype(T::var)>> : true_type {}; \
template <class T> \
constexpr auto has_##var##_v = has_##var<T>::value;
}// namespace internal#line 4 "segment-tree/rbst-segment-tree.hpp"
ENABLE_HAS_VAR(lazy);ENABLE_HAS_VAR(shift);template<typenameNode,typenameI,typenameT,typenameE,T(*f)(T,T),T(*g)(T,E),E(*h)(E,E),T(*ti)(),E(*ei)()>structRBSTSegmentTreeBase{protected:usingPtr=Node*;template<typename...Args>staticPtr_my_new(Args...args){returnnewNode(args...);}staticvoid_my_del(Ptrt){deletet;}staticint_count(constPtrt){returnt?t->cnt:0;}staticT_sum(constPtr&t){returnt?t->sum:ti();}staticuint64_t_rng(){staticuint64_tx_=88172645463325252ULL;returnx_^=x_<<7,x_^=x_>>9,x_&0xFFFFFFFFull;}staticPtr_merge(Ptrl,Ptrr){if(!l||!r)returnl?l:r;if(int((_rng()*(l->cnt+r->cnt))>>32)<l->cnt){_push(l);l->r=_merge(l->r,r);return_update(l);}else{_push(r);r->l=_merge(l,r->l);return_update(r);}}staticPtr_build(intl,intr,constvector<pair<I,T>>&dat){if(l==r)returnnullptr;if(l+1==r)return_my_new(dat[l].first,dat[l].second);intm=(l+r)/2;return_merge(_build(l,m,dat),_build(m,r,dat));};staticvoid_push([[maybe_unused]]Ptrt){ifconstexpr(has_lazy_v<Node>){if(!t)return;if(t->lazy!=ei()){if(t->l)_propagate(t->l,t->lazy);if(t->r)_propagate(t->r,t->lazy);t->lazy=ei();}}ifconstexpr(has_shift_v<Node>){if(!t)return;if(t->shift!=I{}){if(t->l)_shift(t->l,t->shift);if(t->r)_shift(t->r,t->shift);t->shift=I{};}}}staticvoid_propagate([[maybe_unused]]Ptrt,[[maybe_unused]]constE&x){ifconstexpr(has_lazy_v<Node>){if(!t)return;t->lazy=h(t->lazy,x);t->val=g(t->val,x);t->sum=g(t->sum,x);}}staticvoid_shift([[maybe_unused]]Ptrt,[[maybe_unused]]constI&sh){ifconstexpr(has_shift_v<Node>){if(!t)return;t->key+=sh,t->shift+=sh;}}staticPtr_update(Ptrt){if(!t)returnt;t->cnt=1;t->sum=t->val;if(t->l)t->cnt+=t->l->cnt,t->sum=f(t->l->sum,t->sum);if(t->r)t->cnt+=t->r->cnt,t->sum=f(t->sum,t->r->sum);returnt;}// key が k であるノードを探す, なければ nullptrstaticPtr_find(Ptrt,Ik){while(t){_push(t);if(k==t->key)returnt;t=k<t->key?t->l:t->r;}returnnullptr;}staticvoid_erase(Ptr&t,Ik){if(!t)return;_push(t);if(k==t->key){Ptrtl=t->l,tr=t->r;_my_del(t);t=_merge(tl,tr);}elseif(k<t->key){_erase(t->l,k);_update(t);}else{_erase(t->r,k);_update(t);}}// [k 未満, k 以上]staticpair<Ptr,Ptr>_split_by_key(Ptrt,Ik){if(!t)return{nullptr,nullptr};_push(t);if(k==t->key){Ptrtl=t->l;t->l=nullptr;return{tl,_update(t)};}elseif(k<t->key){autos=_split_by_key(t->l,k);t->l=s.second;return{s.first,_update(t)};}else{autos=_split_by_key(t->r,k);t->r=s.first;return{_update(t),s.second};}}// [k 未満, k, k 超過]staticarray<Ptr,3>_split_by_key3(Ptrt,Ik){if(!t)return{{nullptr,nullptr,nullptr}};_push(t);if(k==t->key){Ptrtl=t->l,tr=t->r;t->l=t->r=nullptr;return{{tl,_update(t),tr}};}elseif(k<t->key){autos=_split_by_key3(t->l,k);t->l=s[2];return{{s[0],s[1],_update(t)}};}else{autos=_split_by_key3(t->r,k);t->r=s[0];return{{_update(t),s[1],s[2]}};}}// (-inf, i] の prod について check(prod) の (true / false) で切るtemplate<typenameC>staticpair<Ptr,Ptr>_split_max_right(Ptrt,constC&check,Tprod=ti()){assert(check(prod));if(!t)return{nullptr,nullptr};_push(t);Tp1=f(prod,_sum(t->l));if(check(p1)){prod=p1;}else{autos=_split_max_right(t->l,check,prod);t->l=s.second;return{s.first,_update(t)};}prod=f(prod,t->val);if(!check(prod)){Ptrtl=t->l;t->l=nullptr;return{tl,_update(t)};}p1=f(prod,_sum(t->r));if(check(p1)){return{t,nullptr};}else{autos=_split_max_right(t->r,check,prod);t->r=s.first;return{_update(t),s.second};}}// [i, inf) の prod について check(prod) の (false / true) で切るtemplate<typenameC>staticpair<Ptr,Ptr>_split_min_left(Ptrt,constC&check,Tprod=ti()){assert(check(prod));if(!t)return{nullptr,nullptr};_push(t);Tp1=f(_sum(t->r),prod);if(check(p1)){prod=p1;}else{autos=_split_min_left(t->r,check,prod);t->r=s.first;return{_update(t),s.second};}prod=f(t->val,prod);if(!check(prod)){Ptrtr=t->r;t->r=nullptr;return{_update(t),tr};}p1=f(_sum(t->l),prod);if(check(p1)){return{nullptr,t};}else{autos=_split_min_left(t->l,check,prod);t->l=s.second;return{s.first,_update(t)};}}// [l, inf) である地点に applystaticvoid_apply_left(Ptrt,Il,constE&e){if(!t)return;_push(t);if(t->key<l){_apply_left(t->r,l,e);}elseif(t->key==l){t->val=g(t->val,e);_propagate(t->r,e);}else{_apply_left(t->l,l,e);t->val=g(t->val,e);_propagate(t->r,e);}_update(t);}// [-inf, r) である地点に applystaticvoid_apply_right(Ptrt,Ir,constE&e){if(!t)return;_push(t);if(t->key<r){_propagate(t->l,e);t->val=g(t->val,e);_apply_right(t->r,r,e);}elseif(t->key==r){_propagate(t->l,e);}else{_apply_right(t->l,r,e);}_update(t);}// [l, r) に applystaticvoid_apply(Ptrt,Il,Ir,constE&e){if(!t)return;_push(t);if(t->key<l){_apply(t->r,l,r,e);}elseif(t->key==l){t->val=g(t->val,e);_apply_right(t->r,r,e);}elseif(t->key<r){_apply_left(t->l,l,e);t->val=g(t->val,e);_apply_right(t->r,r,e);}elseif(t->key==r){_apply_left(t->l,l,e);}else{_apply(t->l,l,r,e);}_update(t);}// l 以上staticT_fold_left(Ptrt,Il){if(!t)returnti();_push(t);if(t->key<l){return_fold_left(t->r,l);}elseif(t->key==l){returnf(t->val,_fold_left(t->r,l));}else{Ttl=_fold_left(t->l,l);returnf(f(tl,t->val),_sum(t->r));}}// r 未満staticT_fold_right(Ptrt,Ir){if(!t)returnti();_push(t);if(t->key<r){Ttr=_fold_right(t->r,r);returnf(f(_sum(t->l),t->val),tr);}elseif(t->key==r){return_sum(t->l);}else{return_fold_right(t->l,r);}}staticT_fold(Ptrt,Il,Ir){if(!t)returnti();_push(t);if(t->key<l){return_fold(t->r,l,r);}elseif(t->key==l){returnf(t->val,_fold_right(t->r,r));}elseif(t->key<r){Ttl=_fold_left(t->l,l);Ttr=_fold_right(t->r,r);returnf(f(tl,t->val),tr);}elseif(t->key==r){return_fold_left(t->l,l);}else{return_fold(t->l,l,r);}}// t を根とする木の上で最小の key は? (t が空の場合は failed)staticpair<I,T>_get_min_keyval(Ptrt,constI&failed){if(!t)return{failed,ti()};while(t->l)_push(t),t=t->l;return{t->key,t->val};}// t を根とする木の上で最小の key は? (t が空の場合は failed)staticpair<I,T>_get_max_keyval(Ptrt,constI&failed){if(!t)return{failed,ti()};while(t->r)_push(t),t=t->r;return{t->key,t->val};}// t を根とする木のうち、[0, i の区間 fold が true になる最大の i は何か?// exclusive かつ (空 または[0,右]が真の場合) の場合は failed(inf)// inclusive かつ (空 または[0,0] が偽の場合) の場合は failedtemplate<typenameC,boolexclusive>staticI_max_right(Ptrt,Ccheck,constI&failed){if(!t)returnfailed;_push(t);Ptrnow=t;Tprod_now=ti();[[maybe_unused]]Iprev=failed;while(true){if(now->l!=nullptr){_push(now->l);autopl=f(prod_now,now->l->sum);if(check(pl)){prod_now=pl;}else{now=now->l;continue;}}autopl=f(prod_now,now->val);if(!check(pl)){ifconstexpr(exclusive){returnnow->key;}else{returnnow->l?_get_max_keyval(now->l,failed).first:prev;}}prod_now=pl;if(now->r==nullptr){ifconstexpr(exclusive){returnfailed;}else{returnnow->key;}}_push(now->r);ifconstexpr(!exclusive)prev=now->key;now=now->r;}}// t を根とする木のうち、i, inf) の区間 fold が true になる最小の i は何か?// inclusive かつ (空 または 存在しない) 場合は failed// exlucisve かつ (空 または [左, inf) が真) の場合は failedtemplate<typenameC,boolinclusive>staticI_min_left(Ptrt,Ccheck,constI&failed){if(!t)returnfailed;_push(t);Ptrnow=t;Tprod_now=ti();[[maybe_unused]]Iprev=failed;while(true){if(now->r!=nullptr){_push(now->r);autopr=f(now->r->sum,prod_now);if(check(pr)){prod_now=pr;}else{now=now->r;continue;}}autopr=f(now->val,prod_now);if(!check(pr)){ifconstexpr(inclusive){returnnow->r?_get_min_keyval(now->r,failed).first:prev;}else{returnnow->key;}}prod_now=pr;if(now->l==nullptr){ifconstexpr(inclusive){returnnow->key;}else{returnfailed;}}_push(now->l);ifconstexpr(inclusive)prev=now->key;now=now->l;}}staticvoid_clear(Ptrt){if(!t)return;if(t->l)_clear(t->l);if(t->r)_clear(t->r);_my_del(t);}staticPtr_deepcopy(Ptrt){if(!t)returnnullptr;Ptru=_my_new(*t);if(u->l)u->l=_deepcopy(u->l);if(u->r)u->r=_deepcopy(u->r);returnu;}staticvoid_dump(Ptrt){if(!t)return;_push(t);_dump(t->l);cerr<<"## key = "<<t->key<<",";cerr<<"\tval = "<<t->val<<", ";cerr<<"\tsum = "<<t->sum<<", ";cerr<<"\tchild = ";cerr<<"( ";if(t->l)cerr<<t->l->key;if(!t->l)cerr<<"nil";cerr<<", ";if(t->r)cerr<<t->r->key;if(!t->r)cerr<<"nil";cerr<<" )"<<endl;_dump(t->r);}staticvoid_make_array(Ptrt,vector<pair<I,T>>&v){if(!t)return;_push(t);if(t->l)_make_array(t->l,v);v.emplace_back(t->key,t->val);if(t->r)_make_array(t->r,v);}public:Ptrroot;RBSTSegmentTreeBase():root(nullptr){}RBSTSegmentTreeBase(Ptrt):root(t){}RBSTSegmentTreeBase(constvector<T>xs,constvector<I>&vals={}){if(!vals.empty())assert(xs.size()==vals.size());intn=xs.size();vector<pair<I,T>>dat(n);for(inti=0;i<n;i++)dat[i]={vals.empty()?i:vals[i],xs[i]};root=_build(0,n,dat);}RBSTSegmentTreeBase(RBSTSegmentTreeBase&&rhs)noexcept{root=rhs.root;}RBSTSegmentTreeBase(constRBSTSegmentTreeBase&rhs){root=rhs.root;}~RBSTSegmentTreeBase()=default;usingRBST=RBSTSegmentTreeBase;RBST&operator=(RBST&&rhs)noexcept{root=rhs.root;return*this;}RBST&operator=(constRBST&rhs){root=rhs.root;return*this;}RBSTdeepcopy(){return_deepcopy(root);}friendvoidswap(RBST&lhs,RBST&rhs){swap(lhs.root,rhs.root);}voidswap(RBST&rhs){swap(root,rhs.root);}// destructive ordered _merge (max(lhs) < min(rhs))friendRBSTordered_merge(RBST&lhs,RBST&rhs){assert(lhs.get_max_key()<rhs.get_min_key());returnRBST{_merge(lhs.root,rhs.root)};}// 1 点 値の書き換えvoidset_val(Ii,Tx){autos=_split_by_key3(root,i);if(s[1]==nullptr){s[1]=_my_new(i,x);}else{s[1]->val=x;}root=_merge(_merge(s[0],_update(s[1])),s[2]);}// すでに要素が存在するときに値を set する。おそらく少し早いvoidset_val_fast(Ii,Tx){staticvector<Ptr>ps;ps.clear();Ptrt=root;while(t){_push(t);ps.push_back(t);if(i==t->key)break;t=i<t->key?t->l:t->r;}if(!t){set_val(i,x);return;}t->val=x;for(intj=ps.size()-1;j>=0;j--)_update(ps[j]);}// 1 点取得Tget_val(Ii){Ptrp=_find(root,i);returnp?p->val:ti();}boolexist(Ii){Ptrp=_find(root,i);returnp!=nullptr;}// 1 点 値の書き換え// func の返り値は void !!!!!!(参照された値を直接更新する)voidapply_val(Ii,constfunction<void(T&)>&func){autos=_split_by_key3(root,i);if(s[1]==nullptr)s[1]=_my_new(i);func(s[1]->val);root=_merge(_merge(s[0],_update(s[1])),s[2]);}// 1 点 値の書き換え 値が既に存在するときに早い// func の返り値は void !!!!!!(参照された値を直接更新する)voidapply_val_fast(Ii,constfunction<void(T&)>&func){staticvector<Ptr>ps;ps.clear();Ptrt=root;while(t){_push(t);ps.push_back(t);if(i==t->key)break;t=i<t->key?t->l:t->r;}if(!t){apply_val(i,func);return;}func(t->val);for(intj=ps.size()-1;j>=0;j--)_update(ps[j]);}// 頂点の削除virtualvoiderase(Ii){_erase(root,i);}// 範囲作用voidapply(Il,Ir,constE&e){if(l>=r)return;_apply(root,l,r,e);}voidapply_all(constE&e){_propagate(root,e);}// 範囲取得Tfold(Il,Ir){if(l>=r)returnti();return_fold(root,l,r);}Tfold_all(){return_sum(root);}voidshift(constI&sh){_shift(root,sh);}// key 最小を取得Iget_min_key(Ifailed={}){return_get_min_keyval(root,failed).first;}// key 最大を取得Iget_max_key(Ifailed={}){return_get_max_keyval(root,failed).first;}// (key, val) 最小を取得pair<I,T>get_min_keyval(Ifailed={}){return_get_min_keyval(root,failed);}// (key, val) 最大を取得pair<I,T>get_max_keyval(Ifailed={}){return_get_max_keyval(root,failed);}// (key, val) 最小を poppair<I,T>pop_min_keyval(Ifailed={}){assert(root!=nullptr);autokv=_get_min_keyval(root,failed);erase(kv.first);returnkv;}// (key, val) 最大を取得pair<I,T>pop_max_keyval(Ifailed={}){assert(root!=nullptr);autokv=_get_max_keyval(root,failed);erase(kv.first);returnkv;}// n 未満の i のうち、[i, n) の区間 fold が true になる最小の i は何か?// (存在しない場合は failed を返す)template<typenameC>Imin_left(In,Ccheck,Ifailed){assert(check(ti())==true);auto[x,y]=_split_by_key(root,n);Ires=_min_left<C,true>(x,check,failed);root=_merge(x,y);returnres;}// n 未満の i のうち、(i, n) の区間 fold が true になる最小の i は何か?// (空だったり (左端, n) が 真の場合は minus_infty を返す)template<typenameC>Imin_left_exclusive(In,Ccheck,Iminus_infty){assert(check(ti())==true);auto[x,y]=_split_by_key(root,n);Ires=_min_left<C,false>(x,check,minus_infty);root=_merge(x,y);returnres;}// n 以上の i のうち、[n, i) の区間 fold が true になる最大の i は何か?// (空だったり [n, 右端] が true の場合は infty を返す)template<typenameC>Imax_right(In,Ccheck,Iinfty){assert(check(ti())==true);auto[x,y]=_split_by_key(root,n);Ires=_max_right<C,true>(y,check,infty);root=_merge(x,y);returnres;}// n 以上の i のうち、[n, i] の区間 fold が true になる最大の i は何か?// (存在しない場合は failed を返す)template<typenameC>Imax_right_inclusive(In,Ccheck,Ifailed){assert(check(ti())==true);auto[x,y]=_split_by_key(root,n);Ires=_max_right<C,false>(y,check,failed);root=_merge(x,y);returnres;}// (key 未満, key 以上) で分割// 呼び出し後のオブジェクトは空のセグ木になるpair<RBST,RBST>split_by_key(constI&key){auto[x,y]=_split_by_key(root,key);root=nullptr;returnmake_pair(RBST{x},RBST{y});}// [i, inf) の区間積が (false, true) になる境界で分割// 呼び出し後のオブジェクトは空のセグ木になるtemplate<typenameC>pair<RBST,RBST>split_min_left(constC&check){assert(check(ti())==true);auto[x,y]=_split_min_left(root,check);root=nullptr;returnmake_pair(RBST{x},RBST{y});}// (-inf, i] の区間積が (true, false) になる境界で分割// 呼び出し後のオブジェクトは空のセグ木になるtemplate<typenameC>pair<RBST,RBST>split_max_right(constC&check){assert(check(ti())==true);auto[x,y]=_split_max_right(root,check);root=nullptr;returnmake_pair(RBST{x},RBST{y});}voidclear(){_clear(root),root=nullptr;}intsize(){return_count(root);}boolempty(){return!root;}voiddump(){cerr<<"***** dump start *****"<<endl;_dump(root);cerr<<"****** dump end ******"<<endl;}// 列を配列に変換して返すvector<pair<I,T>>make_array(){vector<pair<I,T>>res;_make_array(root,res);returnres;}};namespaceRBSTSegmentTreeImpl{bool_ei(){returnfalse;}template<typenameI,typenameT,typenameE,T(*f)(T,T),T(*g)(T,E),E(*h)(E,E),T(*ti)(),E(*ei)()>structShiftableLazySegNode{ShiftableLazySegNode*l,*r;Ikey,shift;Tval,sum;Elazy;intcnt;ShiftableLazySegNode(constI&i,constT&t=ti()):l(),r(),key(i),shift(I{}),val(t),sum(t),lazy(ei()),cnt(1){}};template<typenameI,typenameT,typenameE,T(*f)(T,T),T(*g)(T,E),E(*h)(E,E),T(*ti)(),E(*ei)()>usingRBSTShiftableLazySegmentTree=RBSTSegmentTreeBase<ShiftableLazySegNode<I,T,E,f,g,h,ti,ei>,I,T,E,f,g,h,ti,ei>;template<typenameI,typenameT,typenameE,T(*f)(T,T),T(*g)(T,E),E(*h)(E,E),T(*ti)(),E(*ei)()>structLazySegNode{LazySegNode*l,*r;Ikey;Tval,sum;Elazy;intcnt;LazySegNode(constI&i,constT&t=ti()):l(),r(),key(i),val(t),sum(t),lazy(ei()),cnt(1){}};template<typenameI,typenameT,typenameE,T(*f)(T,T),T(*g)(T,E),E(*h)(E,E),T(*ti)(),E(*ei)()>usingRBSTLazySegmentTree=RBSTSegmentTreeBase<LazySegNode<I,T,E,f,g,h,ti,ei>,I,T,E,f,g,h,ti,ei>;template<typenameI,typenameT,T(*f)(T,T),T(*ti)()>structSegNode{SegNode*l,*r;Ikey;Tval,sum;intcnt;SegNode(constI&i,constT&t=ti()):l(),r(),key(i),val(t),sum(t),cnt(1){}};template<typenameI,typenameT,T(*f)(T,T),T(*ti)()>usingRBSTSegmentTree=RBSTSegmentTreeBase<SegNode<I,T,f,ti>,I,T,bool,f,nullptr,nullptr,ti,_ei>;}// namespace RBSTSegmentTreeImplusingRBSTSegmentTreeImpl::RBSTLazySegmentTree;usingRBSTSegmentTreeImpl::RBSTSegmentTree;usingRBSTSegmentTreeImpl::RBSTShiftableLazySegmentTree;/**
* @brief RBST-based Dynamic Lazy Segment Tree
*/#line 6 "verify/verify-yuki/yuki-1786.test.cpp"
//usingnamespaceNyaan;intf(inta,intb){returnmax(a,b);}intg(inta,intb){returna+b;}intti(){return-inf;}intei(){return0;}usingSeg=RBSTLazySegmentTree<ll,int,int,f,g,g,ti,ei>;voidNyaan::solve(){inl(N);intpre=0;Segseg;rep(i,N){inl(A);A^=pre;intmx=seg.fold(A,infLL);intsc=max(0,mx+1);seg.apply(0,A,1);seg.apply(A,infLL,-1);seg.set_val(A,sc);llans=seg.min_left_exclusive(infLL,[](intx){returnx<0;},-infLL);out(ans);pre=ans;}}