from bisect import bisect_left n, k = map(int, input().split()) A = list(map(int, input().split())) L = A[: n // 3] R = A[n // 3 :] def f(A): res = [0] for a in A: le = len(res) for i in range(le): res.append(res[i] + a) res.sort() return res L = f(L) R = f(R) l = -1 << 60 r = 1 << 60 while r - l > 1: m = (l + r) // 2 cnt = 0 for a in L: cnt += len(R) - bisect_left(R, m - a) if cnt < k: r = m else: l = m print(l)