N, K = gets.split.map(&:to_i) A = N.times.map { gets.to_i } dp = Array.new(K + 1, false) dp[0] = true ans = 0 A.each do |a| ans.downto(0) do |v| next unless dp[v] nv = v + a next if K < nv dp[nv] = true ans = nv if ans < nv end end puts ans