from collections import deque import bisect import heapq n,m,k = map(int, input().split()) n+=1 a = list(map(int, input().split())) a.append(0) sum3 = set() for i1 in range(n): now1 = a[i1] for i2 in range(n): now2 = now1+a[i2] for i3 in range(n): sum3.add(now2+a[i3]) sum3 = list(sum3) sum3.sort() bisect.bisect(a,55) ans = 0 for a in sum3: b = m-a i = bisect.bisect(sum3,b)-1 now = a+sum3[i] if(now<=m): ans = max(ans, now) print(ans)