def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]); idx +=1 M = int(input[idx]); idx +=1 K = int(input[idx]); idx +=1 A = list(map(int, input[idx:idx+N])) if N > 0 else [] A.sort(reverse=True) # Sort in descending order # Handle cases where all A are 0 or N=0 if not A or A[0] == 0: print(0) return # Recursive function with memoization (not needed due to small K) def dfs(s, r): if r == 0: return s # Option 1: do not pick, current sum is s not_pick = s # Option 2: pick the best possible a best_a = 0 for a in A: if s + a <= M: best_a = a break if best_a == 0: pick = s # cannot pick any else: pick = dfs(s + best_a, r - 1) return max(pick, not_pick) result = dfs(0, K) print(result) if __name__ == "__main__": main()