An archery coach has
Find the achievable sum (from some pair of two distinct arrows) that is closest to
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of arrows and the target sum.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression.
Print a single integer — the achievable pair-sum closest to KaTeX can only parse string typed expression (smallest such sum if there is a tie).
Input
6 54
10 22 28 29 30 40Output52ExplanationThe pair KaTeX can only parse string typed expression is the closest achievable sum to KaTeX can only parse string typed expression.
Example 2:
Input
11 18
2 -3 5 30 29 15 -16 -28 17 -1 23Output17ExplanationBoth KaTeX can only parse string typed expression and KaTeX can only parse string typed expression are exactly distance 1 from the target 18. Since they are tied, the smaller value, KaTeX can only parse string typed expression, is reported.
Example 3:
Input
2 0
-5 5Output0ExplanationThe only possible pair sums to exactly KaTeX can only parse string typed expression, matching the target exactly.