import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random n,k = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = 0 k-=1 cnt = n*(n-1)//2 - k def calc(x,i): z = 0 for j in a: l = (((j ^ x)>>i) & ((1 << 30)-1)) << i r = l + (1 << i) p = bisect.bisect_left(a,l) q = bisect.bisect_left(a,r) z += q-p #print(x,i,j,l,r,p,q) if l <= j < r: z -= 1 z//=2 #print(x,i,z) return z res = 0 for i in reversed(range(30)): r = calc(ans+(1<= cnt: ans += 1<