2022-06-05 03:22:17 +00:00
|
|
|
#include <iostream>
|
2023-02-26 00:39:10 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
|
|
|
#include <limits>
|
|
|
|
#include <type_traits>
|
2022-06-05 03:22:17 +00:00
|
|
|
|
|
|
|
using std::cin;
|
|
|
|
using std::cout;
|
|
|
|
const char endl = '\n';
|
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
const int N = 1e5 + 5;
|
2022-06-05 03:22:17 +00:00
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
template <typename T>
|
|
|
|
struct LinearBasis
|
|
|
|
: std::enable_if<std::is_unsigned<T>::value, T> {
|
|
|
|
T a[std::numeric_limits<T>::digits];
|
2022-06-05 03:22:17 +00:00
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
LinearBasis() {
|
|
|
|
std::fill(std::begin(a), std::end(a), 0);
|
|
|
|
}
|
2022-06-05 03:22:17 +00:00
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
void insert(unsigned long long x) {
|
|
|
|
for (int i = std::numeric_limits<T>::digits - 1; ~i; i--) {
|
|
|
|
if ((x >> i) & 1) {
|
|
|
|
if (a[i]) {
|
|
|
|
x ^= a[i];
|
|
|
|
} else {
|
|
|
|
a[i] = x;
|
2022-06-05 03:22:17 +00:00
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-06-05 03:22:17 +00:00
|
|
|
}
|
2023-02-26 00:39:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
T query() {
|
|
|
|
T res(0);
|
2022-06-05 03:22:17 +00:00
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
for (int i = std::numeric_limits<T>::digits - 1; ~i; i--) {
|
|
|
|
if ((res ^ a[i]) > res) res ^= a[i];
|
2022-06-05 03:22:17 +00:00
|
|
|
}
|
2023-02-26 00:39:10 +00:00
|
|
|
|
|
|
|
return res;
|
2022-06-05 03:22:17 +00:00
|
|
|
}
|
2023-02-26 00:39:10 +00:00
|
|
|
};
|
2022-06-05 03:22:17 +00:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
std::ios::sync_with_stdio(false);
|
|
|
|
cin.tie(nullptr);
|
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
int n;
|
|
|
|
LinearBasis<unsigned long long> lb;
|
|
|
|
|
2022-06-05 03:22:17 +00:00
|
|
|
cin >> n;
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++) {
|
2023-02-26 00:39:10 +00:00
|
|
|
unsigned long long x;
|
|
|
|
|
2022-06-05 03:22:17 +00:00
|
|
|
cin >> x;
|
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
lb.insert(x);
|
2022-06-05 03:22:17 +00:00
|
|
|
}
|
|
|
|
|
2023-02-26 00:39:10 +00:00
|
|
|
cout << lb.query() << endl;
|
2022-06-05 03:22:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|