from itertools import combinations n, k = map(int, input().split()) b = [int(input()) for _ in range(n)] a = [i for i in b if i < k] maxmum = 0 for num in range(1, n+1): for combi in combinations(a, num): canditate = sum(combi) if canditate == k: print(canditate) break elif canditate < k and maxmum < canditate: maxmum = canditate else: continue break else: print(maxmum)