#!/usr/bin/env python indat = [int(x) for x in input().split()] weights = list() for i in range(indat[0]): x = int(input()) if x < indat[1]: weights.append(x) elif x == indat[1]: print(x) exit() def rec(i,j): if i == len(weights): res = 0 elif j < weights[i]: res = rec(i+1,j) else: res = max(rec(i+1, j), rec(i+1, j-weights[i]) + weights[i]) return res print(rec(0, indat[1]))