n, m, k = map(int, input().split()) a = list(map(int, input().split())) # Handle the case when there are no cards if n == 0: print(0) exit() # Sort the cards in descending order a_sorted = sorted(a, reverse=True) max_a = a_sorted[0] # Initialize dp array where dp[i] is the maximum sum with i draws dp = [0] * (k + 1) for i in range(1, k + 1): current_max = dp[i-1] # Try to take the largest possible a candidate = current_max + max_a if candidate <= m: dp[i] = candidate else: # Find the largest a that can be added without exceeding m found = False for a_val in a_sorted: if current_max + a_val <= m: dp[i] = current_max + a_val found = True break if not found: dp[i] = current_max # cannot draw, keep the previous max # Check if not drawing is better dp[i] = max(dp[i], dp[i-1]) # The answer is the maximum value in dp[0...k] print(max(dp))