from itertools import product from heapq import heappop, heappush # lst内ケーキの選び方すべてにおける嬉しさのリスト def H(lst): ret = [] for pro in product((0, 1), repeat=len(lst)): val = 0 for el, pr in zip(lst, pro): if pr: val += el ret.append(val) ret.sort(reverse=True) return ret def f(i, j): return C[i] + D[j] N, K = map(int, input().split()) A = list(map(int, input().split())) mid = N // 2 A_left, A_right = A[:mid], A[mid:] C, D = H(A_left), H(A_right) hque = [] # (-value, C_idx, D_idx) を格納する。 E = [0] * len(C) heappush(hque, (-f(0, 0), 0, 0)) for _ in range(K - 1): el = heappop(hque) m_val, i, j = el E[i] = j + 1 if j + 1 < len(D): if i == 0 or E[i - 1] > E[i]: heappush(hque, (-f(i, j + 1), i, j + 1)) if i + 1 < len(C) and E[i + 1] == j: heappush(hque, (-f(i + 1, j), i + 1, j)) m_val, i, j = heappop(hque) print(-m_val)