#line 1 "library/Template/template.hpp" #include using namespace std; #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} #line 2 "sol.cpp" // #include "Utility/fastio.hpp" using P=pair; // FastIO io; int main(){ int n,tmp; cin>>n; vector a(n); rep(i,0,n)cin>>a[i]; int gr=0; ll sum=0; set bit[20]; auto process=[&](int k,int x){ sum-=x; gr^=a[k]; rep(j,0,30)if(a[k]>>j&1)bit[j].erase(k); a[k]-=x; gr^=a[k]; rep(j,0,30)if(a[k]>>j&1)bit[j].insert(k); }; auto out=[&](int k,int x,bool done=0)->void{ cout<>tmp; if(done)assert(tmp==-1); else assert(tmp==0); }; auto in=[&]()->P{ int k,x; cin>>k>>x; k--; cin>>tmp; assert(tmp==0); return {k,x}; }; rep(i,0,n){ gr^=a[i]; sum+=a[i]; rep(j,0,20)if(a[i]>>j&1)bit[j].insert(i); } if(gr==0){ cout<<0<=0;j--){ if(gr>>j&1){ assert(bit[j].size()); sel=*bit[j].begin(); break; } } assert(sel!=-1); int x=a[sel]-a[sel]^gr; process(sel,x); out(sel,x,sum==0); if(sum==0)break; auto [k,y]=in(); process(k,y); } return 0; }