N, K = map(int, input().split()) A = [int(input()) for _ in range(N)] dp = [0] * (2*10**6+1) dp[0] = 1 ans = 0 for i in range(N): for j in range(K-A[i], -1, -1): if dp[j]: w = j + A[i] dp[w] = 1 ans = max(ans, w) print(ans)