#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define test int t;cin>>t; while(t--)
#define en '\n'
int maximumXOR(int n, int l, int r)
{
int x = 0;
for (int i = log2(r); i >= 0; --i)
{
if (n & (1 << i))
{
if ((x > r) || (x + (1 << i) - 1 < l))
x ^= (1 << i);
}
else
{
if ((x ^ (1 << i)) <= r)
x ^= (1 << i);
}
}
return n ^ x;
}
int32_t main()
{
// i have already declared int as long long
int n;
cin >> n;
int a[n];
zip(i, 0, n)
{
cin >> a[i];
}
sort(a, a + n);
vi pre(n);
vi suff(n);
pre[0] = a[0];
zip(i, 1, n)
{
pre[i] = (pre[i - 1] ^ a[i]);
}
suff[n - 1] = a[n - 1];
rzip(i, n - 2, 0)
{
suff[i] = (suff[i + 1] ^ a[i]);
}
int ans = suff[0];
zip(i, 0, n - 2)
{
// as we can check only one element first take xor of pre[i]^suf[i+2] and change value accordingly.
int x = pre[i];
int y = suff[i + 2];
x = (x ^ suff[i + 2]);
int p = a[i + 1];
ans = max(ans, maximumXOR(x, 0, p));
}
if (n > 1)
{
ans = max(ans, maximumXOR(suff[1], 0, a[0]));
ans = max(ans, maximumXOR(pre[n - 2], 0, a[n - 1]));
}
cout << ans << en;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCiNkZWZpbmUgdmkgdmVjdG9yPGludD4KI2RlZmluZSB6aXAoaSxhLGIpIGZvcihpbnQgaT1hO2k8YjtpKyspCiNkZWZpbmUgcnppcChpLGEsYikgZm9yKGludCBpPWE7aT49YjtpLS0pCiNkZWZpbmUgdGVzdCBpbnQgdDtjaW4+PnQ7IHdoaWxlKHQtLSkKI2RlZmluZSBlbiAnXG4nCgoKaW50IG1heGltdW1YT1IoaW50IG4sIGludCBsLCBpbnQgcikKewoJ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