package net.ipipip0129.yukicoder.no617; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String line = scan.nextLine(); int count = Integer.parseInt(line.split(" ")[0]); int maxweight = Integer.parseInt(line.split(" ")[1]); List stocks = new ArrayList(); for (int i = 0; i < count; i++) { stocks.add(Integer.parseInt(scan.nextLine())); } scan.close(); int cweight = 0; for (int i = 0; i < stocks.size(); i++) { if (stocks.get(i) <= maxweight) { cweight = stocks.get(i); }else { break; } } if (cweight != maxweight) { for (int i =0; i < stocks.size() / 2; i++) { for (int j = 0; j < stocks.size(); j++) { if (stocks.get(i) != stocks.get(j)) { if (stocks.get(i) + stocks.get(j) <= maxweight) { if (cweight < stocks.get(i) + stocks.get(j)) { cweight = stocks.get(i) + stocks.get(j); } } } } } } System.out.println(cweight); } }