#include using namespace std; const int MaxN = 5e4 + 10; struct Node { int to[2], cnt; } nd[MaxN * 16]; int n, a[MaxN], pr[MaxN], ptr; pair < int, int > t[2 * MaxN]; vector < pair < int, int > > q[MaxN]; long long cur, k; pair < int, int > getPos(int l, int r) { l += n - 1; r += n - 1; pair < int, int > res = make_pair(MaxN, -1); while (l <= r) { if (l & 1) { res = min(res, t[l++]); } if (~r & 1) { res = min(res, t[r--]); } l >>= 1; r >>= 1; } return res; } void add(int l, int r, long long X, int S) { X = min(X, 65535LL); if (l > 0) { q[l - 1].push_back(make_pair(X + 100000, S)); } q[r].push_back(make_pair(X, S)); } void solve(int l, int r, long long x) { int p = getPos(l, r).second; if (p - l <= r - p) { for (int i = l; i <= p; ++i) { add(p, r, x / a[p], pr[i - 1]); } } else { for (int i = p; i <= r; ++i) { add(l - 1, p - 1, x / a[p], pr[i]); } } if (l < p) { solve(l, p - 1, x); } if (p < r) { solve(p + 1, r, x); } } void addNumber(int x) { int root = 0; nd[root].cnt += 1; for (int it = 15; it >= 0; --it) { int bit = (x >> it) & 1; if (nd[root].to[bit] == -1) { nd[root].to[bit] = ++ptr; } root = nd[root].to[bit]; nd[root].cnt += 1; } } int takeL(int y, int x) { int res = 0; int root = 0, nw = 0; for (int it = 15; it >= 0; --it) { if (root == -1) { break; } int bit = (y >> it) & 1; if ((nw | (1 << it)) <= x) { int z = nd[root].to[bit]; res += z != -1 ? nd[z].cnt : 0; root = nd[root].to[bit ^ 1]; nw |= 1 << it; } else { root = nd[root].to[bit]; } } if (nw <= x) { res += root != -1 ? nd[root].cnt : 0; } return res; } int main() { for (int i = 0; i < MaxN * 16; ++i) { nd[i].to[0] = nd[i].to[1] = -1; } // freopen("input.txt", "r", stdin); int tests = 1; // scanf("%d", &tests); while (tests --> 0) { scanf("%d%lld", &n, &k); assert (1 <= n && n <= 50000); assert (1 <= k && k <= 1LL * n * (n + 1) / 2); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); assert (1 <= a[i] && a[i] <= 50000); pr[i] = a[i] ^ pr[i - 1]; t[i + n - 1] = make_pair(a[i], i); } for (int i = n - 1; i > 0; --i) { t[i] = min(t[i + i], t[i + i + 1]); } long long l = 0, r = 50000 * 65535LL, res = -1; while (l <= r) { long long m = (l + r) / 2; cur = 0; solve(1, n, m); for (int i = 0; i <= n; ++i) { addNumber(pr[i]); for (auto it : q[i]) { int x = it.first % 100000, y = it.second; cur += (it.first >= 100000 ? -1 : +1) * takeL(y, x); } } for (int i = 0; i <= ptr; ++i) { nd[i].to[0] = nd[i].to[1] = -1; nd[i].cnt = 0; } for (int i = 0; i <= n; ++i) { q[i].clear(); } ptr = 0; if (cur >= k) { res = m; r = m - 1; } else { l = m + 1; } } printf("%lld\n", res); } return 0; }