import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum INF = 10^^9; class Node { Node L, R; // x -> max(x + lzp, lzq) int mx; int lzp, lzq; this() { mx = 0; lzp = 0; lzq = -INF; } void ch(int p, int q) { mx = max(mx + p, q); lzp += p; lzq = max(lzq + p, q); } void push() { L.ch(lzp, lzq); R.ch(lzp, lzq); lzp = 0; lzq = -INF; } void merge() { mx = max(L.mx, R.mx); } void update(int l, int r, int a, int b, int p, int q) { if (b <= l || r <= a) { return; } if (a <= l && r <= b) { ch(p, q); return; } if (!L) L = new Node; if (!R) R = new Node; push(); const mid = (l + r) >> 1; L.update(l, mid, a, b, p, q); R.update(mid, r, a, b, p, q); merge(); } int solve(int l, int r) { assert(mx > 0); if (!L || !R) { assert(!L && !R); return r - 1; } push(); // writefln("solve [%s,%s) R.mx = %s",l,r,R?R.mx.to!string:"null"); const mid = (l + r) >> 1; const ret = (R.mx > 0) ? R.solve(mid, r) : L.solve(l, mid); merge(); return ret; } }; enum E = 30; void main() { try { for (; ; ) { const N = readInt; auto A = new int[N]; foreach (i; 0 .. N) { A[i] = readInt; } long ans; auto seg = new Node; foreach (i; 0 .. N) { A[i] ^= ans; seg.update(0, 1 << E, 0, A[i] + 1, 1, 0); seg.update(0, 1 << E, A[i] + 1, 1 << E, -1, 0); ans = seg.solve(0, 1 << E); writeln(ans); } debug { writeln("A = ", A); } // break; } } catch (EOFException e) { } }