#int(input()) #map(int, input().split()) #list(map(int, input().split())) N, M, K = map(int, input().split()) A = list(map(int, input().split())) from itertools import product from bisect import bisect_right ans = 0 if 1 <= K <= 3: for i in range(K): for x in product(A, repeat=i+1): s = sum(x) if s <= M: ans = max(ans, s) else: A.append(0) s2 = set() s3 = set() for i in range(3): for x in product(A, repeat=i+1): s = sum(x) if i < 2: s2.add(s) if i < 3: s3.add(s) if K == 4: u = A elif K == 5: u = s2 else: u = s3 s3 = sorted(s3) for x in u: t = bisect_right(s3, M-x) if t != 0: ans = max(ans, x+s3[t-1]) print(ans)