#!/usr/bin/env python import itertools indat = [int(x) for x in input().split()] weights = set() for i in range(indat[0]): weights.add(int(input())) ans = 0 for perm in itertools.permutations(weights): tmp = 0 for l in perm: if tmp + l > indat[1]: break elif tmp + l <= indat[1]: tmp += l continue if tmp == indat[1]: ans = tmp break elif tmp > ans: ans = tmp continue print(ans)