n, m, k = map(int, input().split()) a = list(map(int, input().split())) if n == 0: print(0) else: a.sort(reverse=True) max_a = a[0] dp = [0] * (k + 1) # dp[0] is 0, others are initialized to 0 for t in range(1, k + 1): current_max = 0 # Iterate through all elements in a, sorted descendingly for ai in a: prev = dp[t - 1] candidate = prev + ai if candidate <= m and candidate > current_max: current_max = candidate # Update dp[t] if any valid candidate was found if current_max > 0: dp[t] = current_max else: # If no valid sum, leave it as 0 (but possibly invalid) pass # Keep it as 0, but need to check against M later # Collect all possible dp values and find the maximum <= m max_score = 0 for t in range(k + 1): if dp[t] <= m and dp[t] > max_score: max_score = dp[t] print(max_score)