from bisect import bisect_left, bisect_right # bisect_left(a, x): a[i] >= xとなるような最小のi. # 昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す. # a = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] # s = bisect_left(a,4), s = 2 n, m, k = map(int, input().split()) a = list(map(int, input().split())) + [0] if k >= 4: 0 / 0 if k == 1: ans = 0 for i in a: if ans < i <= m: ans = i print(ans) elif k == 2: b = [x + y for x in a for y in a if x + y <= m] print(max(b)) elif k == 3: b = [x + y for x in a for y in a for z in a if x + y + z <= m] print(max(b)) elif k == 4: b = [x + y + z for x in a for y in a for z in a if x + y + z <= m] b = list(set(b)) b.sort() ans = 0 for i in a: k = bisect_left(b, m - i + 1) if k - 1 >= 0: ans = max(ans, b[k - 1] + i) print(ans) elif k == 5: b = [x + y + z for x in a for y in a for z in a if x + y + z <= m] c = [x + y for x in a for y in a if x + y <= m] b = list(set(b)) b.sort() ans = 0 for i in c: k = bisect_left(b, m - i + 1) if k - 1 >= 0: ans = max(ans, b[k - 1] + i) print(ans) else: b = [x + y + z for x in a for y in a for z in a if x + y + z <= m] b = list(set(b)) b.sort() ans = 0 for i in b: k = bisect_left(b, m - i + 1) if k - 1 >= 0: ans = max(ans, b[k - 1] + i) print(ans)