프로그램 명: coci_jack
제한시간: 1 초

[문제 요약] N개의 카드가 있습니다. 각 카드에는 10만 이하의 자연수가 적혀 있습니다. Mirko는 이 N개의 카드 중 3개를 선택해서 적혀 있는 수들을 더해 임의의 자연수 M을 넘지 않는 가장 가까운 자연수를 만들어야 합니다. Mirko를 도와주세요.

입력


In “Blackjack”, a popular card game, the goal is to have cards which sum up to largest number not exceeding 21. Mirko came up with his own version of this game.

In Mirko.s game, cards have positive integers written on them. The player is given a set of cards and an integer M. He must choose three cards from this set so that their sum comes as close as possible to M without exceeding it. This is not always easy since there can be a hundred of cards in the given set.

Help Mirko by writing a program that finds the best possible outcome of given game.

입력

The first line of input contains an integer N (3 ≤ N ≤ 100), the number of cards, and M (10 ≤ M ≤ 300 000), the number that we must not exceed. The following line contains numbers written on Mirko.s cards: N distinct space-separated positive integers less than 100 000. There will always exist some three cards whose sum is not greater than M.

출력

The first and only line of output should contain the largest possible sum we can obtain.

입출력 예

입력

5 21 
5 6 7 8 9 

출력

21 

입력

10 500 
93 181 245 214 315 36 185 138 216 295 

출력

497
출처:coci 2012 1/6
요약:tncks0121

[질/답] [제출 현황] [푼 후(2)]
[ 채 점 ] [홈으로]  [뒤 로]