n,k = map(int,input().split()) r = [0] for _ in range(n): x = int(input()) r += [x+ri for ri in r] ans = 0 for ri in r: if ans < ri <= k: ans = ri print(ans)