2021-10-02 07:13:33 +00:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2021-10-02 07:19:28 +00:00
|
|
|
int n, a[1000005], trie[10000005][2], p = 1, ans;
|
2021-10-02 07:13:33 +00:00
|
|
|
|
2021-10-02 07:19:28 +00:00
|
|
|
void insert(int u, int x, int b) {
|
|
|
|
if (!x) return;
|
|
|
|
if (!trie[u][(x >> b) & 1]) trie[u][(x >> b) & 1] = ++p;
|
|
|
|
insert(trie[u][(x >> b) & 1], x - (((x >> b) & 1) << b), b - 1);
|
2021-10-02 07:13:33 +00:00
|
|
|
}
|
|
|
|
|
2021-10-02 07:19:28 +00:00
|
|
|
int search(int u, int x) {
|
|
|
|
int res = 0, t = u;
|
2021-10-02 07:13:33 +00:00
|
|
|
for (int i = 30; i >= 0; i--) {
|
2021-10-02 07:19:28 +00:00
|
|
|
if (!t) break;
|
|
|
|
if (trie[t][!((x >> i) & 1)]) {
|
2021-10-02 07:13:33 +00:00
|
|
|
res += 1 << i;
|
2021-10-02 07:19:28 +00:00
|
|
|
t = trie[t][!((x >> i) & 1)];
|
2021-10-02 07:13:33 +00:00
|
|
|
} else {
|
2021-10-02 07:19:28 +00:00
|
|
|
t = trie[t][(x >> i) & 1];
|
2021-10-02 07:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
scanf("%d", &n);
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
scanf("%d", a + i);
|
2021-10-02 07:19:28 +00:00
|
|
|
insert(1, a[i], 30);
|
2021-10-02 07:13:33 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < n; i++) {
|
2021-10-02 07:19:28 +00:00
|
|
|
ans = max(ans, search(1, a[i]));
|
2021-10-02 07:13:33 +00:00
|
|
|
}
|
|
|
|
printf("%d\n", ans);
|
|
|
|
return 0;
|
|
|
|
}
|