// #pragma GCC optimize("Ofast") // #pragma GCC target("avx2,bmi,bmi2,lzcnt") // #define NDEBUG #include #include struct rep { struct iter { int i; constexpr void operator++() { ++i; } constexpr int operator*() const { return i; } friend constexpr bool operator!=(iter a, iter b) { return *a != *b; } }; const int l, r; constexpr rep(int _l, int _r) : l(std::min(_l, _r)), r(_r) {} constexpr rep(int n) : rep(0, n) {} constexpr iter begin() const { return {l}; } constexpr iter end() const { return {r}; } }; struct per { struct iter { int i; constexpr void operator++() { --i; } constexpr int operator*() const { return i; } friend constexpr bool operator!=(iter a, iter b) { return *a != *b; } }; const int l, r; constexpr per(int _l, int _r) : l(std::min(_l, _r)), r(_r) {} constexpr per(int n) : per(0, n) {} constexpr iter begin() const { return {r - 1}; } constexpr iter end() const { return {l - 1}; } }; template constexpr bool chmin(T& a, U&& b) { return b < a ? a = std::forward(b), true : false; } template constexpr bool chmax(T& a, U&& b) { return a < b ? a = std::forward(b), true : false; } int main() { using namespace std; cin.tie(nullptr)->sync_with_stdio(false); int n, x; cin >> n >> x; vector a(n); for (auto&& e : a) cin >> e; vector> p(30); for (int s : rep(30)) for (int i : rep(n + 1)) if (i == n or (a[i] >> s & 1) != ((i ? a[i - 1] : x) >> s & 1)) p[s].push_back(i); int64_t ans{}; for (int s : rep(30)) for (int k : rep(1, size(p[s]))) { int l = p[s][k - 1], r = p[s][k]; if (s + 1 < 30 and binary_search(begin(p[s + 1]), end(p[s + 1]), l) and binary_search(begin(p[s + 1]), end(p[s + 1]), r) and (a[l] >> s & 1) != (a[l] >> (s + 1) & 1)) continue; ans += 1 << s; } cout << ans << '\n'; }