//: https://codeforces.com/contest/1055/submission/232368836 // LUOGU_RID: 134589272 #include #include typedef long long ll; typedef double lf; // #define DEBUG 1 struct IO { #define MAXSIZE (1 << 20) #define isdigit(x) (x >= '0' && x <= '9') char buf[MAXSIZE], *p1, *p2; char pbuf[MAXSIZE], *pp; #if DEBUG #else IO() : p1(buf), p2(buf), pp(pbuf) {} ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);} #endif #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++) #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t') template void Read(T &x) { #if DEBUG std::cin >> x; #else bool sign = 0; char ch = gc(); x = 0; for (; !isdigit(ch); ch = gc()) if (ch == '-') sign = 1; for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48); if (sign) x = -x; #endif } void Read(char *s) { #if DEBUG std::cin >> s; #else char ch = gc(); for (; blank(ch); ch = gc()); for (; !blank(ch); ch = gc()) *s++ = ch; *s = 0; #endif } void Read(char &c) {for (c = gc(); blank(c); c = gc());} void Push(const char &c) { #if DEBUG putchar(c); #else if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf; *pp++ = c; #endif } template void Write(T x) { if (x < 0) x = -x, Push('-'); static T sta[35]; int top = 0; do sta[top++] = x % 10, x /= 10; while (x); while (top) Push(sta[--top] ^ 48); } template void Write(T x, char lst) {Write(x), Push(lst);} } IO; #define Read(x) IO.Read(x) #define Write(x, y) IO.Write(x, y) #define Put(x) IO.Push(x) using namespace std; const int MAXN = 2e5 + 10; int n, fa[MAXN]; ll k, w[MAXN], ans; int top[2]; int l1[2][MAXN], r1[2][MAXN], l2[2][MAXN], r2[2][MAXN], mid1[MAXN], mid2[MAXN]; inline int FindMid(int l, int r, int s) { int mid = l - 1; while (mid < r && !((w[mid + 1] >> s) & 1)) mid++; return mid; } int main() { #if DEBUG #else ios::sync_with_stdio(0), cin.tie(0); #endif Read(n), Read(k); k = n + 2 * k; for (int i = 1; i <= n; i++) Read(w[i]); sort(w + 1, w + n + 1); int p = 0; top[0] = 1, l1[0][1] = l2[0][1] = 1, r1[0][1] = r2[0][1] = n; for (int s = 30; s >= 0; s--) { ll sum = 0; for (int i = 1; i <= top[p]; i++) { mid1[i] = FindMid(l1[p][i], r1[p][i], s), mid2[i] = (l2[p][i] == l1[p][i] ? mid1[i] : FindMid(l2[p][i], r2[p][i], s)); sum += (ll)(mid1[i] - l1[p][i] + 1) * (mid2[i] - l2[p][i] + 1) + (ll)(r1[p][i] - mid1[i]) * (r2[p][i] - mid2[i]); } int np = p ^ 1; top[np] = 0; if (sum >= k) { for (int i = 1; i <= top[p]; i++) { if (mid1[i] >= l1[p][i] && mid2[i] >= l2[p][i]) top[np]++, l1[np][top[np]] = l1[p][i], r1[np][top[np]] = mid1[i], l2[np][top[np]] = l2[p][i], r2[np][top[np]] = mid2[i]; if (mid1[i] < r1[p][i] && mid2[i] < r2[p][i]) top[np]++, l1[np][top[np]] = mid1[i] + 1, r1[np][top[np]] = r1[p][i], l2[np][top[np]] = mid2[i] + 1, r2[np][top[np]] = r2[p][i]; } } else { k -= sum, ans ^= (1ll << s); for (int i = 1; i <= top[p]; i++) { if (mid1[i] >= l1[p][i] && mid2[i] < r2[p][i]) top[np]++, l1[np][top[np]] = l1[p][i], r1[np][top[np]] = mid1[i], l2[np][top[np]] = mid2[i] + 1, r2[np][top[np]] = r2[p][i]; if (mid1[i] < r1[p][i] && mid2[i] >= l2[p][i]) top[np]++, l1[np][top[np]] = mid1[i] + 1, r1[np][top[np]] = r1[p][i], l2[np][top[np]] = l2[p][i], r2[np][top[np]] = mid2[i]; } } p = np; } Write(ans, '\n'); return 0; }