import bisect n, m, k = map(int, input().split()) a = list(map(int, input().split())) + [0] l = set() r = set() for vi in a: for vj in a: for vk in a: if k < 5: vk = 0 if k < 3: vj = 0 l.add(vi+vj+vk) if k < 6: vk = 0 if k < 4: vj = 0 r.add(vi+vj+vk) l = sorted(list(l)) r = sorted(list(r)) ans = 0 for v in l: if v > m: break idx = bisect.bisect_right(r, m-v) - 1 ans = max(ans, v+r[idx]) print(ans)