N,K = map(int,input().split()) products = [int(input()) for x in range(N)] dp = [0] * (K + 1) for i in range(1,K + 1): for product in products: if product <= i: dp[i] = max(dp[i - 1],dp[i - product] + product) print(dp[K])