import sys from heapq import heapify,heappop,heappush input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N,K=mi() A=li() if N==1: ans=[0,A[0]] ans.sort(reverse=True) print(ans[K-1]) else: n=N//2 m=N-n C=[] D=[] for bit in range(1<>i)&1)*A[i] C.append(cnt) for bit in range(1<>i)&1)*A[i+n] D.append(cnt) C.sort(reverse=True) D.sort(reverse=True) h=[(-(c+D[0]),i,0) for i,c in enumerate(C)] #print(h) heapify(h) for _ in range(K-1): a,b,c=heappop(h) if c!=(1<