Blackjack

Time limit1sMemory limit128 MB

Problem

Blackjack is a popular card game where the goal is to make the largest possible card sum without going over 21. This problem uses a modified version of that idea.

Each card has one positive integer written on it. The dealer lays N cards face up on the floor and announces a target number M.

The player must choose three distinct cards from the N cards. The sum of the chosen cards must not exceed M, and it should be as close to M as possible.

Given the numbers written on the cards, print the maximum sum of three cards that does not exceed M.

Input

The first line contains the number of cards N (3 <= N <= 100) and the target number M (10 <= M <= 300,000).

The second line contains N positive integers written on the cards. Each number is at most 100,000.

The input is guaranteed to contain at least one choice of three cards whose sum does not exceed M.

Output

Print the sum of three cards that is closest to M without exceeding M.