#include #include using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define Inf 1000000001 template struct dynamic_lazy_segtree { struct node{ int nxt[2]; S v; F lz; node(){ nxt[0] = -1; nxt[1] = -1; v = e(); lz = id(); } }; vector nodes; dynamic_lazy_segtree() : dynamic_lazy_segtree(0) {} dynamic_lazy_segtree(long long n){ log = 0; while((1LL< t(1,0); for(int i=log-1;i>=0;i--){ t.push_back(get(t.back(),(p>>i)&1)); } rep(i,t.size()-1){ push(t[i]); } reverse(t.begin(),t.end()); rep(i,t.size()){ if(i==0)nodes[t[i]].v = x; else{ update(t[i]); } } } S get(long long p) { assert(0 <= p && p < _n); int cur = 0; for(int i=log-1;i>=0;i--){ push(cur); cur = get(cur,(p>>i)&1); } return nodes[cur].v; } S prod(long long l,long long r,int cur,int depth){ if(cur==-1||r-l==0)return e(); if(r-l==(1LL<>(depth-1))&1){ l ^= 1LL<<(depth-1); r ^= 1LL<<(depth-1); return prod(l,r+1,nodes[cur].nxt[1],depth-1); } if(((r>>(depth-1))&1)==0){ return prod(l,r+1,nodes[cur].nxt[0],depth-1); } r ^= 1LL<<(depth-1); return op(prod(l,1LL<<(depth-1),nodes[cur].nxt[0],depth-1),prod(0,r+1,nodes[cur].nxt[1],depth-1)); } S prod(long long l, long long r) { assert(0 <= l && l <= r && r <= _n); return prod(l,r,0,log); } S all_prod() { return nodes[0].v; } void apply(long long p,F f){ assert(0 <= p && p < _n); vector t(1,0); for(int i=log-1;i>=0;i--){ t.push_back(get(t.back(),(p>>i)&1)); } rep(i,t.size()-1){ push(t[i]); } reverse(t.begin(),t.end()); rep(i,t.size()){ if(i==0)nodes[t[i]].v = mapping(f,nodes[t[i]].v); else{ update(t[i]); } } } void apply(long long l,long long r,int cur,int depth,F f){ if(r-l==0)return; if(r-l==(1LL<>(depth-1))&1){ l ^= 1LL<<(depth-1); r ^= 1LL<<(depth-1); apply(l,r+1,get(cur,1),depth-1,f); } else if(((r>>(depth-1))&1)==0){ apply(l,r+1,get(cur,0),depth-1,f); } else{ r ^= 1LL<<(depth-1); apply(l,1LL<<(depth-1),get(cur,0),depth-1,f); apply(0,r+1,get(cur,1),depth-1,f); } update(cur); return; } void apply(long long l,long long r,F f){ assert(0 <= l && l <= r && r <= _n); apply(l,r,0,log,f); } void update(int k){ nodes[k].v = e(); rep(i,2){ if(nodes[k].nxt[i]==-1)continue; nodes[k].v = op(nodes[k].v,nodes[nodes[k].nxt[i]].v); } } void all_apply(int k, F f) { nodes[k].v = mapping(f, nodes[k].v); nodes[k].lz = composition(f, nodes[k].lz); } void push(int k) { rep(i,2){ int t = get(k,i); all_apply(t,nodes[k].lz); } nodes[k].lz = id(); } long long _n,log; }; int op(int a,int b){ return max(a,b); } int e(){ return 0; } int mapping(int a,int b){ return a+b; } int composition(int a,int b){ return a+b; } int id(){ return 0; } int main(){ int last = 0; dynamic_lazy_segtree seg((1<<30)+5); int N; scanf("%d",&N); rep(i,N){ int A; scanf("%d",&A); A ^= last; seg.apply(0,A+1,1); int ok = A+1,ng = (1<<30)+1; while(ng-ok>1){ int mid = (ok+ng)/2; if(seg.get(mid-1)==0)ng = mid; else ok = mid; } seg.apply(A+1,ok,-1); ok = 0,ng = (1<<30)+1; while(ng-ok>1){ int mid = (ok+ng)/2; if(seg.get(mid)==0)ng = mid; else ok = mid; } printf("%d\n",ok); last = ok; } return 0; }