N, K = map(int, input().split()) A = [int(input()) for _ in range(N)] W = {0} for a in A: W.update([a + x for x in W if a + x <= K]) print(max(W))