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