#include #include #define LIM 1000011 /////////////////////// struct tree { int t0, t1; }; tree _[LIM*12]; #define ROOT 1 int count; int new_node() { ++count; _[count].t0 = _[count].t1 = 0; return count; } int rev(int value, int it) { // reverse value's last 'it' bits int res = 0; while (it--) { res <<= 1; res |= value & 1; value >>= 1; } return res; } int _add(int t, int value, int it) { // add a new value to the trie if (!t) { t = new_node(); } if (it) { if (value & 1) { _[t].t1 = _add(_[t].t1, value >> 1, it - 1); } else { _[t].t0 = _add(_[t].t0, value >> 1, it - 1); } } return t; } int _get(int t, int value, int it, int stack = 0) { // add a new value to the trie if (it) { int son = value & 1 ? _[t].t0 : _[t].t1; if (son) { return _get(son, value >> 1, it - 1, (stack << 1) | 1); } else { son = value & 1 ? _[t].t1 : _[t].t0; return _get(son, value >> 1, it - 1, (stack << 1)); } } else { return stack; } } /////////////////////// int ans; void init() { count = 0; _add(0, 0, 30); ans = 0; } int get(int value) { value = rev(value, 30); int nans = _get(ROOT, value, 30); _add(ROOT, value, 30); if (ans < nans) ans = nans; return ans; } /////////////////////// int a[LIM]; int ansl[LIM]; int main() { int n; scanf("%d", &n); init(); for (int i = 0, value = 0; i < n; i++) { scanf("%d", a + i); ansl[i] = get(value ^= a[i]); } init(); int ans = 0; for (int i = n-1, value = 0; i;) { int ansr = get(value ^= a[i]); int bago = ansl[--i] + ansr; if (ans < bago) ans = bago; } printf("%d\n", ans); }