PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000185. Bảng điểm toàn A (Straight A's)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bảng điểm toàn A (Straight A's)

Straight A's

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Noora has nn integer marks in her school register. Every mark lies between 11 and the maximum mark kk. Her graduation mark is the arithmetic mean of all marks, rounded to the nearest integer, with exact half-integers rounded up. Noora wants to obtain graduation mark kk. You may append additional integer marks between 11 and kk, but must append as few as possible. Find that minimum number.

Input

Line 1 contains two integers nn and kk: the number of existing marks and the maximum possible mark.

Line 2 contains exactly nn integers a1,a2,…,ana_1,a_2,\ldots,a_n, the existing marks in their register order.

Output

Print one integer: the minimum number of additional marks needed to make the rounded graduation mark equal to kk.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101\le n\le 10; 1≤k≤101\le k\le 10; 1≤ai≤k1\le a_i\le k for every 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤401\le n\le 40; 1≤k≤501\le k\le 50; 1≤ai≤k1\le a_i\le k for every 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n≤1001\le n\le 100; 1≤k≤1001\le k\le 100; 1≤ai≤k1\le a_i\le k for every 1≤i≤n1\le i\le n.

Examples

Example 1

Input

2 10
8 9

Output

4

Explanation

The current marks are 88 and 99, totaling 1717. Appending qq marks of 1010 yields an average (17+10q)/(2+q)(17+10q)/(2+q). To round to 1010, it must reach 9.59.5. With q=3q=3 the average is 47/5=9.447/5=9.4, too low; with q=4q=4 it is 57/6=9.557/6=9.5 and rounds up to 1010. The answer is 44.

Example 2

Input

3 5
4 4 4

Output

3

Explanation

The three existing marks total 1212. Adding three marks of 55 gives total 2727 over six marks, average 4.54.5, which rounds up to 55. Adding only two marks of 55 would give 22/5=4.422/5=4.4, which is insufficient.