from itertools import combinations n, k = map(int, input().split()) a = [int(input()) for _ in range(n)] 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)