using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace YukiCoder { class Program { static void Main(string[] args) { var va = Console.ReadLine().Split().Select(int.Parse).ToArray(); var ha = new List() { 0 }; for (int i = 0; i < va[0]; i++) { int na = int.Parse(Console.ReadLine()); var hb = ha.Select(n => n + na).ToList(); ha.AddRange(hb); ha = ha.Distinct().ToList(); } int nMax = ha.Where(n => n <= va[1]).Max(); Console.WriteLine(nMax); Console.ReadLine(); } } }