package tmp; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); } Arrays.sort(A); boolean[] f = new boolean[20 * 100000 + 1]; f[0] = true; for (int i = 0; i < N; ++i) { for (int j = f.length - 1; j >= 0; --j) { if (f[j]) { f[j + A[i]] = true; } } } for (int i = K; i >= 0; --i) { if (f[i]) { System.out.println(i); return; } } } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }