Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.

In school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. 

For instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.

To graduate with «A» certificate, Noora has to have mark k.

Noora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.


-----Input-----

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.

The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.


-----Output-----

Print a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.


-----Examples-----
Input
2 10
8 9

Output
4
Input
3 5
4 4 4

Output
3


-----Note-----

Consider the first example testcase.

Maximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.

In the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.

Difficulty: EASY
Tags: Mathematics

Implementation

Starter code:

Solutions:
import math
import re

def f(n):
	if n - math.floor(n) < 0.5:
		return n
	else:
		return math.ceil(n)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
n1 = n
s = sum(a)
sred = s / n
while f(sred) != k:
	s += k
	n += 1
	sred = s / n
print(n - n1)


3.5
(n, k) = [int(x) for x in input().split()]
mas = [int(x) for x in input().split()]
p = 0
s = sum(mas)
while True:
	if s / n >= k - 0.5:
		print(p)
		quit()
	else:
		s += k
		n += 1
		p += 1


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
sk = (2 * m - 1) * n - 2 * sum(arr)
if sk < 0:
	print(0)
else:
	print(sk)


import math
string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
string = input()
s = sum(list(map(int, string.split())))
n = 0

def roundup(x):
	if x - math.floor(x) < 0.5:
		return math.floor(x)
	else:
		return math.ceil(x)
while roundup(s / a) < b:
	s += b
	a += 1
	n += 1
print(n)


(n, k) = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
(a, i) = (0, 0)
while (sum(x) + i * k) / n < k - 0.5:
	i += 1
	n += 1
print(i)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
c = 0
while s / n < k - 0.5:
	s += k
	n += 1
	c += 1
print(c)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
r = sum(l)
j = 1
z = 0
s = r
if r / n >= m - 0.5:
	print(0)
else:
	while j > 0:
		s += m
		p = s / (j + n)
		z = int(p)
		if z + 0.5 <= p:
			if z + 1 == m:
				print(j)
				break
		j += 1


import sys
input = sys.stdin.readline

def io():
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	return (n, k, ls)

def solve():
	(n, k, ls) = io()
	sm = sum(ls)
	a = sm / len(ls)
	avg = round(a)
	if a - avg >= 0.5:
		avg += 1
	ans = 0
	while avg < k:
		ls.append(k)
		sm += k
		n += 1
		a = sm / n
		avg = round(a)
		if a - avg >= 0.5:
			avg += 1
		ans += 1
	print(ans)
solve()


import math
(n, k) = map(int, input().split())
sm = sum(list(map(int, input().split())))
a = 0
while int((sm + a * k) / (n + a) + 0.5) < k:
	a += 1
print(a)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x = 2 * (n * (k - 0.5) - sum(a))
print(max(0, int(x)))


from math import ceil
(n, k) = map(int, input().split())
li = list(map(int, input().split()))
count = 0
count2 = 0

def round1(n):
	k = int(n)
	b = n - k
	if b >= 0.5:
		return ceil(n)
	return k
while round1(sum(li) / len(li)) != k:
	li.append(k)
	count += 1
print(count)


(n, k) = map(int, input().split())
A = sum(list(map(int, input().split())))
print(max(2 * n * k - n - 2 * A, 0))


j = input()
j = list(map(int, j.split(' ')))
n = j[0]
k = j[1]
j = input()
j = list(map(int, j.split(' ')))
su = sum(j)
le = len(j)
c = 0
while su / le < k - 0.5:
	su += k
	le += 1
	c += 1
print(c)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
s = sum(L)
x = 0
while True:
	if ((x + n) * (2 * k - 1) + 1) // 2 <= s + k * x <= k * (x + n):
		print(x)
		break
	x += 1


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
curSum = 0
result = 0
for i in range(n):
	curSum += a[i]
while abs(k - curSum / n) > 0.5:
	result += 1
	n += 1
	curSum += k
print(result)


from math import *
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
sum1 = sum(arr)
if round(sum1 / n) == k:
	print(0)
else:
	count = 0
	while sum1 / n < k - 0.5:
		sum1 += k
		count += 1
		n += 1
	print(count)


(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
s = sum(l)
total = len(l)
res = 0
while s < total * k - total / 2:
	s += k
	total += 1
	res += 1
print(res)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
p = (k - 0.5) * n
if s >= p:
	print(0)
else:
	r = int(2 * (p - s))
	print(r)


(n, k) = map(int, input().split())
s = sum(map(int, input().split()))
print(max(0, n * k * 2 - n - s * 2))


(n, k) = (int(i) for i in input().split())
sm = 0
for i in input().split():
	sm += int(i)
f = (sm / (k - 0.5) - n) / (1 - k / (k - 0.5))
if f < 0:
	print(0)
else:
	print(int(f // 1 + (f % 1 > 1e-05)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
f = k - 1 / 2
ans = 0
while sum(a) / len(a) < f:
	a.append(k)
	ans += 1
print(ans)


import decimal
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
ans = 0
if int(decimal.Decimal(str(s / n)).to_integral_value()) == k:
	print(0)
else:
	while True:
		ans += 1
		s += k
		n += 1
		if int(decimal.Decimal(str(s / n)).to_integral_value()) == k:
			print(ans)
			break


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
s = sum(l)
req = k - 0.5
if s >= n * req:
	print(0)
	return
for i in range(1, 100000):
	if s + k * i >= (n + i) * req:
		print(i)
		return


import sys
s = sys.stdin.read().strip().split('\n')
k = int(s[0].split()[1])
t = int(s[0].split()[0])
s = list(map(int, s[1].split()))
n = 0
a = sum(s)
while a / t < k - 0.5:
	a += k
	t += 1
	n += 1
print(n)


import math
(length, max) = map(int, input().split())
vct = map(int, input().split())
sum = 0
out = 0
target = max - 1 + 0.5
for x in vct:
	sum += x
while sum / (length + out) < target:
	sum += max
	out += 1
print(out)


(a, b) = map(int, input().split())
l = sum(list(map(int, input().split())))
n = 0
while l / (a + n) < b - 0.5:
	l += b
	n += 1
print(n)


(x, y) = list(map(int, input().split()))
a = list(map(int, input().split()))
n = 0
d = 0
for i in range(x):
	n = n + a[i]
while round((n + 0.01) / x) != y:
	n = n + y
	x = x + 1
	d += 1
print(d)


(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
s = sum(marks)
q = 0
while s < n * (k - 0.5):
	q += 1
	s += k
	n += 1
print(q)


(n, k) = map(int, input().split())
grades = list(map(int, input().split()))
ans = (2 * k - 1) * n - 2 * sum(grades)
if ans < 0:
	ans = 0
print(ans)


(n, k) = input().split()
n = int(n)
k = int(k)
s = [int(x) for x in input().split()]
punkty = 0
for x in s:
	punkty += k - x
print(max(punkty * 2 - n, 0))


(n, k) = map(int, input().split())
m = list(map(int, input().split()))

def av(m):
	return sum(m) / len(m)
s = sum(m)

def ro(x):
	xx = int(x)
	if x - xx >= 0.5:
		return xx + 1
	else:
		return xx
pren = n
while s / n < k - 0.5:
	s += k
	n += 1
print(n - pren)


(n, k) = input().split()
n = int(n)
k = int(k)
a = input().split()
a = list(map(int, a))
s = sum(a)
m = 0
while True:
	if s / (n + m) >= k - 0.5:
		break
	m += 1
	s += k
print(m)


import math
(n, k) = map(int, input().split())
s = 0

def x(i):
	global s
	s += int(i)
list(map(x, input().split()))
ave = 0
o = 0
while True:
	a = 2 * (s + o * k)
	b = (2 * k - 1) * (n + o)
	if a >= b:
		break
	o += 1
print(o)


[n, k] = list(map(int, input().split()))
a = list(map(int, input().split()))
tot = 0
for e in a:
	tot += e
lo = 0
hi = 1 << 30
while lo < hi:
	md = (lo + hi) // 2
	if (tot + k * md) // (n + md) >= k or 2 * (tot + k * md) >= (n + md) * (2 * k - 1):
		hi = md
	else:
		lo = md + 1
print(lo)


(x, k) = map(int, input().split())
S = list(map(int, input().split()))
sx = sum(S)
g = k - 0.5
y = 0
while True:
	if sx + k * y >= g * (x + y):
		print(y)
		break
	y += 1


a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
sum1 = 0
for i in b:
	sum1 += i
n = a[0]
while sum1 / n < a[1] - 0.5:
	n += 1
	sum1 += a[1]
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
a = (2 * k - 1) * n - 2 * sum(d)
if a < 0:
	a = 0
print(a)


import math
(n, k) = map(int, input().split())
s = sum(map(int, input().split()))
print(max(0, (2 * k - 1) * n - 2 * s))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
avg = round(sum(a) / n, 10)
while avg < k - 0.5:
	i += 1
	avg = round((sum(a) + i * k) / (n + i), 10)
print(i)


def roun(n):
	if n < int(n + 0.5):
		return int(n) + 1
	else:
		return int(n)
from math import ceil
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
sl = sum(l)
i = 1
no_of_k = 0
avg = roun(sl / n)
while avg < k:
	avg = roun((sl + i * k) / (n + i))
	i += 1
	no_of_k += 1
print(no_of_k)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = sum(l)
num = 0
if sum(l) / n >= k - 0.5:
	print(num)
else:
	while True:
		s += k
		num += 1
		if s / (num + n) >= k - 0.5:
			print(num)
			break


(n, k) = map(int, input().split())
a = sum(map(int, input().split()))
ans = 0
while a / n < k - 0.5:
	a += k
	n += 1
	ans += 1
print(ans)


(n, k) = map(int, input().split())
import math
a = math.ceil(2 * n * k - 2 * sum(map(int, input().split())) - n)
print([0, a][a > 0])


(n, k) = map(int, input().split())
sm = 0
ch = 0
a = [int(i) for i in input().split()]
for i in a:
	sm += i
while float(sm) / n < float(k) - 0.5:
	sm += float(k)
	ch += 1
	n += 1
print(ch)


(n, k) = list(map(int, input().split()))
m = list(map(int, input().split()))
add = int(((k - 0.5) * n - sum(m)) // 0.5)
if add > 0:
	print(add)
else:
	print(0)


import math
(n, k) = map(int, input().split())
SUM = sum(map(int, input().split()))
Nach = n
while SUM / n < k - 0.5:
	n += 1
	SUM += k
print(n - Nach)


import math

def main():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	if sum(a) / n >= k - 0.5:
		print(0)
		return
	m = math.ceil(((k - 0.5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - 0.5)))
	print(int(m))
main()


import sys
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
sum_ = sum(a)
len_ = len(a)
while sum_ / len_ < k - 0.5:
	sum_ += k
	len_ += 1
	c += 1
print(c)


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
ans = 0
if sum(l) / n < k - 0.5:
	ans = int(((k - 0.5) * n - sum(l)) / 0.5)
print(ans)


(n, k) = [int(p) for p in input().split()]
a = [int(p) for p in input().split()]
s = sum(a)
i = 0
while (s + i * k) / (len(a) + i) < k - 0.5:
	i += 1
print(i)


import math
(n, k) = map(int, input().split())
amt = 0
nums = [int(x) for x in input().split()]
amt = sum(nums)
ans = 2 * n * k - n - 2 * amt
print(math.ceil(ans) if ans >= 0 else 0)


def Main():
	(n, k) = map(int, input().split())
	sm = 0
	arr = list(map(int, input().split()))
	sm = sum(arr)
	N = n
	cnt = 0
	while (sm + N // 2) // N < k:
		sm += k
		N += 1
		cnt += 1
	print(cnt)
Main()


L = input()
L = L.split()
n = int(L[0])
a = int(L[1])
notas = input()
notas = notas.split()
for k in range(n):
	notas[k] = int(notas[k])
aux = 0
for k in range(n):
	aux += notas[k]
promedio = aux / n
count = 0
k = 0
while promedio < a - 0.5:
	k += 1
	aux += a
	promedio = aux / (n + k)
print(k)


import sys
read = lambda : sys.stdin.readline().rstrip()
readi = lambda : int(sys.stdin.readline())
writeln = lambda x: sys.stdout.write(str(x) + '\n')
write = lambda x: sys.stdout.write(x)
(N, K) = map(int, read().split())
S = sum(list(map(int, read().split())))
X = 2 * K * N - 2 * S - N
if 2 * K >= 2 * S / float(N) + 1:
	writeln(X)
else:
	writeln(0)


import sys
(n, k) = input().split()
n = int(n)
k = float(k)
a = [int(x) for x in input().split()]
s = 0
for i in range(n):
	s += a[i]
if s / n >= k - 0.5:
	print('0')
	sys.exit()
x = 0
while s / n < k - 0.5:
	s += k
	n += 1
	x += 1
print(x)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
while 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):
	ans += 1
print(ans)


X = list(map(int, input().split()))
Grades = list(map(int, input().split()))
i = 0
while (sum(Grades) + i * X[1]) / (len(Grades) + i) < X[1] - 0.5:
	i += 1
print(i)


import math
line = lambda : map(int, input().split())

def solve():
	(n, k) = line()
	s = sum(line())
	print(max(0, (k + k - 1) * n - s - s))

def main():
	solve()
	exit(0)
main()


import sys
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = sum(l)
ans = ((k - 0.5) * n - s) * 2
if ans < 0:
	print(0)
else:
	print(int(ans))


(n, k) = map(int, input().split())
(s, ans) = (sum(list(map(int, input().split()))), 0)
while s / (n + ans) < k - 0.5:
	s += k
	ans += 1
print(ans)


(n, k) = map(int, input().split())
maxMark = k
marks = [int(x) for x in input().split()]
k -= 0.5
sumMarks = sum(marks)
numMarks = len(marks)
average = sumMarks / numMarks
cost = 0
while average < k:
	sumMarks += maxMark
	cost += 1
	numMarks += 1
	average = sumMarks / numMarks
print(cost)


from math import ceil
Input = lambda : map(int, input().split())
(n, k) = Input()
a = list(Input())
add = 0
SUM = sum(a)
while True:
	Y = SUM / n
	if ceil(Y) - Y <= 0.5:
		Ave = ceil(Y)
	else:
		Ave = SUM // n
	if Ave < k:
		SUM += k
		n += 1
		add += 1
	else:
		break
print(add)


l1 = [int(x) for x in input().split()]
(n, k) = (l1[0], l1[1])
sumo = sum([int(x) for x in input().split()])
ans = 0
while (2 * k - 1) * (n + ans) > 2 * k * ans + 2 * sumo:
	ans += 1
print(ans)


(n, k) = map(int, input().split())
mrks = list(map(int, input().split()))
ns = sum(mrks)
reqm = (k - 0.5) * n
if ns < reqm:
	dff = reqm - ns
	res = dff * 2
	res = int(round(res))
	print(res)
else:
	print(0)


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
z = sum(s)
x = a
while z / a < b - 0.5:
	z += b
	a += 1
print(a - x)


def grade(ar):
	z = sum(ar) / len(ar)
	f = int(z)
	s = z - f
	if s >= 0.5:
		return f + 1
	else:
		return f
(x, y) = map(int, input('').split())
ar = list(map(int, input('').split()))
q = grade(ar)
ct = 0
while q < y:
	ct = ct + 1
	ar.append(y)
	q = grade(ar)
print(ct)


(a, b) = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
d = sum(s)
for i in range(10000000000):
	if d + b * i >= b * (a + i) - (a + i) / 2:
		print(i)
		break


import math
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
s = sum(arr)
x = (s - n * (k - 0.5)) / -0.5
print(math.ceil(max(0, x)))


def alex(a, k):
	current_round = sum(a) / len(a)
	if current_round + 0.5 >= k:
		return 0
	ans = 2 * (k * len(a) - 0.5 * len(a) - sum(a))
	return ans
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
print(int(alex(a, k)))


def check(m):
	return (s + k * m) * 2 >= (2 * k - 1) * (n + m)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
l = -1
r = 10 ** 6
while l < r - 1:
	m = (l + r) // 2
	if check(m):
		r = m
	else:
		l = m
print(r)


inputs = [int(i) for i in input().split()]
marks = [int(i) for i in input().split()]

def is_k(ss, req, aa, ll):
	ss += req * aa
	avg = ss / (ll + aa)
	kk = round(avg)
	return kk == req or avg == req - 0.5
ss = sum(marks)
ll = len(marks)
amount = 0
while not is_k(ss, inputs[1], amount, ll):
	amount += 1
print(amount)


(n, k) = map(int, input().split())
X = k - 0.5
su = sum(map(int, input().split()))
result = round((su - X * n) / (X - k))
print(str(max(0, result)))


IL = lambda : list(map(int, input().split()))
I = lambda : int(input())
(n, k) = IL()
a = IL()
print(max(sum([k - i for i in a]) * 2 - n, 0))


(m, n) = map(int, input().split())
li = list(map(int, input().split()))
fl = 0
su = sum(li)
av = su / m
while av < n - 0.5:
	su = su + n
	m = m + 1
	av = su / m
	fl = fl + 1
print(fl)


def read():
	return map(int, input().split())
(n, k) = read()
s = sum(read())
print(max(0, n * (2 * k - 1) - 2 * s))


(a, b) = map(int, input().split())
mark = list(map(int, input().split()))
suma = sum(mark)
ans = 0
if round(sum(mark) / a) == b:
	print(0)
	exit()
else:
	while round(suma / a + 1e-14) != b:
		suma += b
		a += 1
		ans += 1
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a) / len(a)
count = 0
while ans < k - 0.5:
	a.append(k)
	ans = sum(a) / len(a)
	count += 1
print(count)


import sys

def solve():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	tot = sum(a)
	cnt = 0
	while (n + cnt) * (2 * k - 1) > 2 * tot:
		tot += k
		cnt += 1
	print(cnt)
solve()


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = sum(a)
l = len(a)
amount = s / l
it = 0
while amount < k - 0.5:
	it += 1
	amount = (s + k * it) / (l + it)
print(it)


(n, k) = map(int, input().split())
a = input()
l = list(map(int, a.split(' ')))
sum = 0
for i in range(0, n):
	sum += l[i]
count = 0
x = round(sum / n)
pp = sum / n - int(sum / n)
if pp == 0.5:
	x = sum / n + 0.5
while int(x) < k:
	sum += k
	n += 1
	count += 1
	x = round(sum / n)
	pp = sum / n - int(sum / n)
	if pp == 0.5:
		x = sum / n + 0.5
print(count)


import math
(n, k) = [int(x) for x in input().split()]
grades = [int(x) for x in input().split()]
answer = (2 * k - 1) * n - 2 * sum(grades)
if answer > 0:
	print(answer)
else:
	print(0)


(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
tad = k
tom = k - 1 + 0.5
lol = sum(p)
s = 0
for x in range(55555555):
	if lol / n >= tom:
		print(s)
		break
	else:
		n += 1
		if (lol + k) / n < tom:
			k += tad
			s += 1
		else:
			print(s + 1)
			break


(n, k) = (int(x) for x in input().split())
grades = [int(x) for x in input().split()]
grade_s = sum(grades)
for i in range(100000):
	if (grade_s + k * i) / (i + n) >= (2 * k - 1) / 2:
		print(i)
		exit()


def round_(i):
	if i % int(i) < 0.5:
		return int(i)
	else:
		return int(i) + 1
a = input().split(' ')
(n, k) = (int(a[0]), int(a[1]))
eps = 1e-16
marks = [int(i) for i in input().split(' ')]
if round_(sum(marks) / len(marks)) == k:
	ans = 0
else:
	ans = (len(marks) * (k - 0.5) - sum(marks)) * 2
	if ans % int(ans) > eps:
		ans = int(ans) + 1
print(int(ans))


(n, k) = tuple((int(i) for i in input().strip().split(' ')))
a = input().strip().split(' ')
sum = 0
o = 0
for i in a:
	sum += int(i)
if sum / n >= k - 0.5:
	print(0)
	exit(0)
while sum / n < k - 0.5:
	sum += k
	n += 1
	o += 1
print(o)


from functools import reduce

def main():
	inputs = input().split(' ')
	n = int(inputs[0])
	maxMarks = int(inputs[1])
	reqAvg = maxMarks - 0.5
	currentTotal = reduce(lambda x, y: y + x, list(map(lambda x: int(x), input().split(' '))))
	average = 0
	result = -1
	while average < reqAvg:
		result += 1
		average = (currentTotal + maxMarks * result) / (n + result)
	print(result)
main()


[n, k] = map(int, input().split())
s = list(map(int, input().split()))
if sum(s) / n >= k - 0.5:
	print(0)
else:
	print(2 * n * k - n - 2 * sum(s))


def solve():
	(n, k) = list((int(x) for x in input().split()))
	sum = 0
	for x in input().split():
		sum += int(x)
	for i in range(0, 100000):
		if sum + i * k >= (k - 0.5) * (i + n):
			print(i)
			return
solve()


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
s = sum(A)
print(max(0, N * (2 * K - 1) - 2 * s))


(n, k) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
add = round(2 * ((k - 0.5) * n - sum(a)) + 0.1)
if add <= 0:
	print(0)
else:
	print(add)


import math
(n, k) = map(int, input().split())
daf = list(map(int, input().split()))
jum = sum(daf)
has = (n * (k - 0.5) - jum) / 0.5
has = math.ceil(has)
print(max(0, has))


def main():
	(n, k) = map(int, input().split())
	a = sum(map(int, input().split()))
	print(max((k * 2 - 1) * n - a * 2, 0))
main()


(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
total = sum(marks)
count = 0
while round(total / n + 1e-13) < k:
	total = total + k
	count = count + 1
	n = n + 1
print(count)


(n, k) = map(int, input().strip().split())
a = input().strip().split(' ')
pk = k - 0.5
fl = True
s = 0
c = 0
for i in a:
	s += int(i)
sa = s / len(a)
while fl:
	if sa < pk:
		c += 1
		a.append(k)
		s += k
		sa = s / len(a)
	else:
		fl = False
print(c)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
curSum = sum(a)
result = 0
while abs(k - curSum / n) > 0.5:
	result += 1
	n += 1
	curSum += k
print(result)


(n, k) = map(int, input().split())
(s, v) = (sum(map(int, input().split())), 0)
while (n + v) * k - s > s - (n + v) * (k - 1):
	(v, s) = (v + 1, s + k)
print(v)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
c = 0
for i in range(n):
	z = k - a[i]
	c += 2 * z - 1
if c < 0:
	print(0)
else:
	print(c)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
d = defaultdict(int)
f = defaultdict(int)
(n, k) = M()
l = L()
s = sum(l)
print(max(2 * n * k - 2 * s - n, 0))


import math
(n, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
ans = max(0, math.ceil(((k - 0.5) * n - sum(a)) * 2))
print(ans)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
count = 0
sum_ = sum(a)
c = n
while sum_ / c < k - 0.5:
	count += 1
	sum_ += k
	c += 1
print(count)


import math
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
ppp = sum(a) / n
if ppp < k - 0.5:
	bb = abs((k - 0.5) * n - sum(a))
	cc = abs(k - 0.5 - k)
	print(int(bb / cc))
else:
	print(0)


(n, k) = map(int, input().split())
r = n
tot = 0.0
for i in input().split():
	tot += float(i)
for i in range(0, 100000000000):
	if tot / r >= k - 0.5:
		print(r - n)
		exit()
	tot += k
	r += 1


(n, k) = map(int, input().split())
grades = sum(list(map(int, input().split())))
count = n
while grades / count < k - 0.5:
	grades += k
	count += 1
print(count - n)


import sys
(n, k) = map(int, input().split())
L = list(map(int, input().split()))
s = sum(L)
i = 0
while 1:
	y = (i * k + s) / (n + i)
	if y <= k and k - y <= 0.5:
		print(i)
		sys.exit(0)
	elif y > k and y - k < 0.5:
		print(i)
		sys.exit(0)
	i += 1


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
s = sum(a)
while s / n < k - 0.5:
	s += k
	n += 1
	ans += 1
print(ans)


(n, k) = map(int, input().split())
a = map(int, input().split())
s = sum(a)
if round(s / (n * 1.0)) == k:
	print(0)
else:
	print(2 * k * n - n - 2 * s)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
avg = sum(l) / len(l)
s = sum(l)
l1 = len(l)
count = 0
while avg < k - 0.5:
	count += 1
	s += k
	l1 += 1
	avg = s / l1
print(count)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
s = 0
for i in a:
	s += i
while s / n + 0.5 < k:
	s += k
	cnt += 1
	n += 1
print(cnt)


(n, k) = input().split()
n = int(n)
k = int(k)
s = input()
s = s.split()
count = 0
c = 1
sum = 0
for a in s:
	sum += int(a)
avg = sum / n
if avg >= k - 0.5:
	c = 0
while c == 1:
	if avg >= k - 0.5:
		c = 0
	else:
		sum += k
		n += 1
		avg = sum / n
		count += 1
print(count)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
avg = 0
for i in a:
	avg += i
sr = avg / n
wyn = 0
while sr < k - 0.5:
	wyn += 1
	avg += k
	n += 1
	sr = avg / n
print(wyn)


from math import trunc
(n, k) = map(int, input().split())
print(max(0, trunc((n * (k - 0.5) - sum(list(map(int, input().split())))) / 0.5)))


(x, y) = map(int, input().split())
list1 = list(map(int, input().split()))
z = 0
for i in list1:
	z += 2 * y - 2 * i - 1
if z >= 0:
	print(z)
else:
	print(0)


import statistics

def main():
	(N, K) = map(int, input().split())
	A = tuple(map(int, input().split()))
	sum_ = sum(A)
	ave = sum_ / N
	i = 1
	while True:
		if ave >= K - 0.5:
			break
		else:
			sum_ += K
			ave = sum_ / (N + i)
		i += 1
	print(i - 1)
main()


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
print(max(0, (2 * k - 1) * len(l) - 2 * sum(l)))


(n, k) = map(int, input().split())
a = map(int, input().split())
print(max(0, (n * (k * 10 - 5) - sum(a) * 10) // 5))


(n, k) = [int(i) for i in input().split()]
marks = [int(i) for i in input().split()]
marks = sum(marks)
avg = marks / n
c = 0
while marks / n < k - 0.5:
	marks += k
	n += 1
	c += 1
print(c)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
(count, add) = (0, 0)
av = sum(l) / len(l)
if av == int(av) + 0.5:
	avg = int(av) + 1
else:
	avg = round(av)
while avg != k:
	count += 1
	add += k
	av = (sum(l) + add) / (len(l) + count)
	if av == int(av) + 0.5:
		avg = int(av) + 1
	else:
		avg = round(av)
print(count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
m = s / n
t = k - 1 + 0.5
l = 0
while m < t:
	s += k
	n += 1
	m = s / n
	l += 1
print(l)


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def ptlist(l):
	print(' '.join([str(x) for x in l]))
(n, k) = mp()
a = lt()
x = sum(a)
pt(int(max(2 * ((k - 0.5) * n - x), 0)))


(n, k) = input().split()
(n, k) = (int(n), int(k))
a = list(map(int, input().split()))
p = (2 * k - 1) * n - 2 * sum(a)
if p < 0:
	print(0)
else:
	print(p)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sumA = sum(a)
eps = 1e-13
sA = round(sumA / n + eps)
res = 0
while sA < k:
	sumA += k
	n += 1
	res += 1
	sA = round(sumA / n + eps)
print(res)


firstIn = input()
(n, k) = (int(x) for x in firstIn.split())
secIn = input()
grades = [float(x) for x in secIn.split()]
suma = 0
steps = 0
for i in range(n):
	suma = suma + grades[i]
while suma / n < k - 0.5:
	suma = suma + k
	n += 1
	steps += 1
print(steps)


def func(x, y):
	if x / y - x // y >= 0.5:
		return x // y + 1
	else:
		return x // y
(n, k) = [int(i) for i in input().split()]
s = sum([int(i) for i in input().split()])
sr = s / n
j = 0
sr = func(s, n)
while sr != k:
	s += k
	n += 1
	j += 1
	sr = func(s, n)
print(j)


import os
import sys
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
a = array()
A = (k - 0.5) * n - sum(a)
B = k - (k - 0.5)
print(max(int(Ceil(A, B)), 0))


import math
(n, k) = map(int, input().split())
s = sum(list(map(int, input().split())))
print([0, math.ceil(2 * n * k - n - 2 * s)][math.ceil(2 * n * k - n - 2 * s) > 0])


(n, k) = map(int, input().strip().split())
a = input()
b = list(map(int, a.strip().split()))
sum = 0
for x in b:
	sum += x
cnt = 0
while 1:
	temp = sum / n
	if int(temp + 0.5) >= k:
		break
	sum += k
	n += 1
	cnt += 1
print(cnt)


(n, k) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
s = sum(a)
print(max(0, 2 * k * n - n - 2 * s))


import math
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
s = sum(arr)
c = 0
while 1:
	if math.ceil((s + c * k) / (n + c) - 0.49999) == k:
		break
	c += 1
print(c)


a = list(map(int, input().split()))
a = a[1]
k = a - 0.5
b = list(map(int, input().split()))
g = 0
f = 0
for i in b:
	g += i
	f += 1
s = 0
while g / f < k:
	g += a
	f += 1
	s += 1
print(s)


(n, k) = map(int, input().split())
li = list(map(int, input().split()))
res = (2 * k - 1) * n - sum(li) * 2
if res > 0:
	print(res)
else:
	print('0')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
t = len(a)
l = sum(a)
while True:
	if l / t >= k - 0.5:
		break
	l += k
	t += 1
print(t - len(a))


import math
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
f = k - 1 / 2
while sum(l) / len(l) < f:
	c += 1
	l.append(k)
print(c)


s = input()
l = s.split()
n = int(l[0])
k = int(l[1])
m = input()
list1 = m.split()
t = 0
sum = 0
i = 0
while t < n:
	sum += int(list1[t])
	t += 1
while sum / n < k - 0.5:
	n += 1
	sum += k
	i += 1
print(i)


from math import *
(n, k) = map(int, input().split())
ocl = list(map(int, input().split()))
sum1 = 0
for i in ocl:
	sum1 += i
kol = len(ocl)
tn = 0
while True:
	if (sum1 + tn * k) / (tn + kol) % 1 >= 0.5:
		ts = ceil((sum1 + tn * k) / (tn + kol))
	else:
		ts = int((sum1 + tn * k) / (tn + kol))
	if ts == k:
		break
	else:
		tn += 1
print(tn)


(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
m = 2 * (n * k - sum(a)) - n
print(m if m > 0 else 0)


(n, k) = [int(x) for x in input().split()]
grades = [int(i) for i in input().split()]
l = 0
for y in grades:
	o = k - y
	l += o
Out = l * 2 - n
if Out < 0:
	print(0)
else:
	print(Out)


inp = input().split()
n = int(inp[0])
k = int(inp[1])
inp = input().split()
reg = list(map(int, inp))
s = sum(reg)
x = n * (2 * k - 1) - 2 * s
print(max(x, 0))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sum(a)
result = 0
while b / n < k - 0.5:
	b += k
	n += 1
	result += 1
print(result)


(n, k) = map(int, input().split())
s = sum(map(int, input().split()))
left = -1
right = 10 ** 100
while right - left > 1:
	mid = (left + right) // 2
	whole = s + k * mid
	if whole * 2 // (mid + n) < 2 * k - 1:
		left = mid
	else:
		right = mid
print(right)


(n, m) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
avg = sum(l)
t = 0
while avg < (t + n) * (m - 0.5):
	avg = avg + m
	t += 1
print(t)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a) / n
b = sum(a)
i = 0
while s < k - 0.5:
	i += 1
	n += 1
	s = (b + i * k) / n
print(i)


(n, k) = map(int, input().split())
l = input()
l = [int(i) for i in l.split()]
d = sum(l)
(t, r) = (0, 0)
if round(d / n) == k or d / n == k - 1 + 0.5:
	print(0)
else:
	n = n + 1
	while True:
		d = d + k
		r = d / n
		t += 1
		n += 1
		if round(r) == k or r == k - 1 + 0.5:
			print(t)
			break


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = len(a)
s = sum(a)
cur = round(s / l + 1e-07)
count = 0
while cur != k:
	s += k
	l += 1
	cur = round(s / l + 1e-07)
	count += 1
print(count)


while True:
	try:
		(a, b) = map(int, input().split())
		c = input().split()
		sum = 0
		d = a
		for i in range(0, a):
			sum += float(c[i])
		while True:
			ans = sum / a
			if ans >= b:
				break
			elif ans + 0.5 >= b:
				break
			a += 1
			sum += b
		print(a - d)
	except EOFError:
		break


from math import floor, ceil

def round_(n):
	if n - int(n) < 0.5:
		return floor(n)
	else:
		return ceil(n)
(n, k) = map(int, input().split())
s = sum((int(i) for i in input().split()))
x = 0
while round_((s + k * x) / (n + x)) != k:
	x += 1
print(x)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
l = n
if round(s / n) >= k or k - 0.5 == s / n:
	print(0)
else:
	for i in range(100000000):
		s += k
		l += 1
		temp = s / l
		if k - 0.5 == temp:
			break
		if round(temp) >= k:
			break
	print(l - n)


from math import ceil
(n, k) = [int(i) for i in input().strip().split()]
arr = [int(i) for i in input().strip().split()]
s = sum(arr)
x = 2 * ((k - 0.5) * n - s)
print(int(ceil(x)) if x > 0 else 0)


(n, k) = map(int, input().split())
su = sum(list(map(int, input().split())))
avg = su / n
i = 0
while avg < k - 0.5:
	su += k
	i += 1
	n += 1
	avg = su / n
print(i)


import math
(n, k) = [int(i) for i in input().split()]
m = sum([int(i) for i in input().split()])
print(max(math.ceil(2 * (n * (k - 0.5) - m)), 0))


(n, k) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
cur = sum(A)
i = 0
while cur + i * k < (i + n) * (k - 0.5):
	i += 1
print(i)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
print(max(0, (2 * k - 1) * n - 2 * sum(a)))


(n, k) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
s = sum(l)
if s / n >= k - 0.5:
	print(0)
else:
	ans = (n * k - 0.5 * n - s) / 0.5
	print(int(ans))


(n, k) = map(int, input().split())
lists = list(map(int, input().split()))
sums = sum(lists)
(l, r) = (-1, 10 ** 1000)
m = (l + r) // 2
while r - l != 1:
	if 2 * (sums + k * m) >= (2 * k - 1) * (len(lists) + m):
		r = m
		m = (l + r) // 2
	else:
		l = m
		m = (l + r) // 2
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
cnt = n
need = k - 0.5
while s < cnt * need:
	cnt += 1
	s += k
print(cnt - n)


(a, b) = map(int, input().split())
r = list(map(int, input().split()))
s = sum(r)
k = 0
while (s + b * k) * 2 < (2 * b - 1) * (a + k):
	k += 1
print(k)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) / n >= k - 0.5:
	print('0')
else:
	w = 2 * n * k - n - 2 * sum(a)
	print(w)


import math
import sys
import math
(n, c) = map(int, input().split())
sum = sum(list(map(int, input().split())))
count = 0
while sum / n < c - 0.5:
	sum += c
	n += 1
	count += 1
print(count)


(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
res = 0
sumz = sum(marks)
countz = n
while int(0.5 + sumz / countz) < k:
	res += 1
	sumz += k
	countz += 1
print(res)


readints = lambda : map(int, input().split(' '))
(n, k) = readints()
a = list(readints())
ans = 0
while True:
	cur = sum(a) / len(a)
	if abs(cur - k) <= 0.5:
		break
	ans += 1
	a.append(k)
print(ans)


import sys

def solve():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	s = sum(a)
	cnt = (2 * k - 1) * n - 2 * s
	if cnt < 0:
		cnt = 0
	print(cnt)
solve()


def mid(list):
	return sum(list) / len(list)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
t = 0
mid = mid(a)
s = sum(a)
while mid < k - 0.5:
	s += k
	n += 1
	mid = s / n
	t += 1
print(t)


import math
(n, k) = input().split()
n = int(n)
k = int(k)
s = input().split()
sum = 0
for x in s:
	sum = sum + int(x)
ar = sum / n
if ar + 0.5 < k:
	print('%d' % math.ceil(2.0 * (n * 1.0 * (k - 0.5) - sum)))
else:
	print(0)


from sys import stdin, stdout
import math
(n, k) = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))
ans = sum(values)
cnt = 0

def round(v):
	if math.ceil(v) - v <= 1 / 2:
		return math.ceil(v)
	else:
		return math.floor(v)
while round(ans / n) < k:
	ans += k
	n += 1
	cnt += 1
stdout.write(str(cnt))


in1 = input()
in2 = input()
in1 = in1.split()
in11 = int(in1[0])
in12 = int(in1[1])
in2 = in2.split()
s = 0
for i in in2:
	s += int(i)
n = 0
r = (n * in12 + s) / (in11 + n)
while r < in12 - 0.5:
	n = n + 1
	r = (n * in12 + s) / (in11 + n)
print(n)


I = lambda : map(int, input().split())
(n, k) = I()
a = list(I())
s = sum(a)
x = 0
while k - 0.5 > (s + x * k) / (n + x):
	x += 1
print(x)


import math
(n, k) = list(map(int, input().split()))
s = sum(list(map(int, input().split())))
p = k - 0.5
times = 0
while True:
	if s / (n + times) >= p:
		print(times)
		break
	s += k
	times += 1


def cndtn(s, n):
	avg = s / n
	if avg < int(avg) + 0.5:
		return int(avg)
	else:
		return int(avg) + 1
[n, k] = list(map(int, input().split()))
arr = list(map(int, input().split()))
s = sum(arr)
cnt = 0
if cndtn(s, n) == k:
	print(0)
else:
	while 1:
		cnt += 1
		s += k
		if cndtn(s, n + cnt) == k:
			print(cnt)
			break


(n, naib) = map(int, input().split())
a = list(map(int, input().split()))
dop = 0
s = 0
for i in range(n):
	s += a[i]
while dop != -1:
	if (s + naib * dop) / (n + dop) >= naib - 0.5:
		print(dop)
		dop = -2
	dop += 1


import sys
import os
import math
(n, k) = map(int, input().split())
A = list(map(int, input().split()))

def round(x):
	return (x * 2 + 1) // 2
sum_A = sum(A)
l = len(A)
for i in range(0, 100000000):
	m = (sum(A) + i * k) / (i + l)
	if round(m) >= k:
		print(i)
		exit()


__author__ = 'artyom'

def main():
	(n, k) = read(3)
	s = sum(read(3))
	c = 0
	g = k - 0.5
	while s / n < g:
		s += k
		n += 1
		c += 1
	return c

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


(n, k) = map(int, input().split())
mass = list(map(int, input().split()))
res = 0
summa = sum(mass)
while summa < n * (k - 0.5):
	summa += k
	res += 1
	n += 1
print(res)


(n, k) = map(int, input().split())
tot = sum(map(int, input().split()))
i = 0
while tot * 2 < (k * 2 - 1) * (n + i):
	i += 1
	tot += k
print(i)


from math import ceil
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]

def sr(d):
	return sum(a) / n
m = sr(a)
i = 0
while True:
	if (m * n + k * i) / (n + i) >= k - 0.5:
		print(i)
		break
	i += 1


def apprch(n):
	if n * 10 % 10 >= 5:
		return int(n) + 1
	else:
		return int(n)
sum = 0
counter = 0
avg = 0
inputone = input().split()
n = int(inputone[0])
k = int(inputone[1])
marks = input()
marks = marks.split()
for i in marks:
	sum += int(i)
avg = sum / n
while apprch(avg) < k:
	counter += 1
	sum += k
	avg = sum / (n + counter)
print(counter)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = 0
s = sum(b)
a0 = a[0]
a1 = a[1]
while 1 > 0:
	if s / a0 >= a1 - 0.5:
		break
	else:
		s += a1
		a0 += 1
		k += 1
print(k)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
m = 0
s = sum(a)
(l, r) = (-1, 1000000)
while r - l > 1:
	m = (l + r) // 2
	if (sum(a) + m * k) * 2 < (n + m) * (2 * k - 1):
		l = m
	else:
		r = m
print(r)


raw1 = input().split(' ')
n = int(raw1[0])
k = float(raw1[1])
raw2 = input().split(' ')
avg = 0
for idx in raw2:
	avg += int(idx)
add = 0
while (k - 0.5) * (len(raw2) + add) > avg:
	avg += k
	add += 1
print(add)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
m = 0
t = sum(lst)
a = t / n
while a < (2 * k - 1) / 2:
	t += k
	n += 1
	a = t / n
	m += 1
	lst.append(k)
print(m)


import math

def roundoff(avg):
	decimal = avg - int(avg)
	if decimal >= 0.5:
		return math.ceil(avg)
	else:
		return math.floor(avg)
(_, maxmark) = input().split(' ')
maxmark = int(maxmark)
marks = list(map(int, input().split(' ')))
sums = 0
for i in marks:
	sums += i
curravg = sums / len(marks)
curravg = roundoff(curravg)
if curravg >= maxmark:
	print(0)
else:
	count = 0
	while curravg < maxmark:
		sums += maxmark
		marks += [maxmark]
		curravg = sums / len(marks)
		curravg = roundoff(curravg)
		count += 1
	print(count)


from functools import reduce
import math
nk = input().split()
n = int(nk[0])
k = int(nk[1])
L = list(map(int, input().split()))
s = reduce(lambda x, y: x + y, L)
if round(s / n) == k:
	print(0)
else:
	z = 2 * n * k - 2 * s - n
	print(max(0, z))


(n, k) = map(int, input().split())
a = map(int, input().split())
s = sum(a)
k1 = k - 0.5
m = 0
av = s / n
while av < k1:
	m += 1
	s += k
	av = s / (n + m)
print(m)


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
i = 0
d = 0
j = len(c)
for i in range(j):
	d += c[i]
p = ((b - 0.5) * a - d) * 2
if p < 0:
	print(0)
else:
	print(int(p))


(n, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
print(int(max(0, 2 * (n * (k - 0.5) - sum(nums)))))


(n, k) = map(int, input().split(' '))
marks = [int(i) for i in input().split(' ')]
i = 1
sum_ = sum(marks)
avMarks = sum_ / n
while True:
	if avMarks >= k - 0.5:
		break
	else:
		sum_ += k
		avMarks = sum_ / (n + i)
	i += 1
print(i - 1)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = 0
while 1:
	if round((sum(l) + k * m) / (n + k)) < m:
		if (sum(l) + k * m) / (n + k) % 1 == 0.5 and round((sum(l) + k * m) / (n + k) - 0.5) + 1 >= m:
			break
		k = k + 1
	else:
		break
print(k)


import math
(n, k) = map(int, input().split())
num = list(map(int, input().split()))
sum = 0
for i in range(len(num)):
	sum += num[i]
if float(sum) / n > k - 0.5:
	p = 0
else:
	p = 2 * sum + n - 2 * n * k
print(abs(p))


import math
s = input()
n = int(s.split()[0])
k = int(s.split()[1])
st = input()
i = 1
arr = list(map(int, st.split()))
j = (sum(arr) + k * i) / (len(arr) + i)
if j - math.trunc(j) >= 0.5:
	j = math.ceil(j)
else:
	j = math.trunc(j)
if j == k:
	print(0)
else:
	while True:
		j = (sum(arr) + k * i) / (len(arr) + i)
		if j - math.trunc(j) >= 0.5:
			j = math.ceil(j)
		else:
			j = math.trunc(j)
		if j == k:
			print(i)
			break
		i += 1


import math

def solve():
	(n, k) = list((int(x) for x in input().split()))
	s = 0
	for x in input().split():
		s += int(x)
	print(max(0, (k + k - 1) * n - s - s))

def main():
	solve()
	exit(0)
main()


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
sm = sum(a)
p = 0
while (sm + p * k) / (n + p) < k - 0.5:
	p += 1
print(p)


import time
marks = []
(n, k) = map(int, input().split())
marks = input().split()
marks = list(map(int, marks))
extra = 0
while sum(marks) + extra * k - (extra + len(marks)) * (k - 0.5) < 0:
	extra += 1
print(extra)


(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
ans = int((n * k - 0.5 * n - sum(l)) * 2)
print(ans if ans >= 0 else 0)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
z = sum(a) / n
if k - 0.5 <= z < k + 0.5:
	print(0)
else:
	for i in range(1, 100000):
		s = sum(a) + k * i
		s = s / (n + i)
		if k - 0.5 <= s < k + 0.5:
			print(i)
			break


from decimal import *
(n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
su = sum(s)
res = 0
avg = Decimal(su / n).quantize(0, ROUND_HALF_UP)
while avg < k:
	su += k
	n += 1
	res += 1
	avg = Decimal(su / n).quantize(0, ROUND_HALF_UP)
print(res)


import math
a = input().split()
b = int(a[0])
c = int(a[1])
e = input().split()
e = list(map(int, e))
f = e
e = sum(e)
g = 0
y = c
c = b
b = e
a = y
x = (b + 0.6 * c - a * c) / -0.6
math.floor(x)
x = x - 3
if x < 0:
	x = 0
e = (b + x * a) / (c + x)
while e < a - 0.5:
	x += 1
	e = (b + x * a) / (c + x)
print(int(x))


(n, k) = map(int, input().split())
a = list(map(lambda x: int(x) * 10, input().split()))
(n, k) = (n * 10, k * 10)
su = sum(a)
d = len(a)
s = su // d
if s % 10 >= 5:
	s += 10
num = 0
while s < k:
	su += k
	d += 1
	s = su // d
	if s % 10 >= 5:
		s += 10
	num += 1
print(num)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
count = 0
sym = sum(A)
while sym / n < k - 0.5:
	sym += k
	n += 1
	count += 1
print(count)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
avg = 0
count = 0
i = 0
while True:
	avg = sum(arr) / (n + i)
	avg = avg + 0.5
	avg = str(avg)
	x = avg.find('.')
	avg = avg[:x]
	avg = int(avg)
	i += 1
	if avg == k:
		break
	if avg != k:
		arr.append(k)
		count += 1
print(count)


(n, k) = map(int, input().split())
MM = list(map(int, input().split()))
pp = sum(MM)
l = n
while pp / l < k - 0.5:
	pp = pp + k
	l += 1
print(l - n)


def average(ns):
	return sum(ns) / len(ns)

def main():
	t = [int(x) for x in input().split()]
	n = t[0]
	k = t[1]
	ns = [int(y) for y in input().split()]
	if round(average(ns)) == k:
		print(0)
	else:
		print(int(-2 * (sum(ns) - k * n + 0.5 * n)))
main()


(n, k) = map(int, input().split(' '))
l = sum((int(x) for x in input().split()))
a = round(l / n)
if l / n + 0.5 == k:
	a = k
added = 0
if a == k:
	print(added)
else:
	while a != k:
		l += k
		added += 1
		n += 1
		if l / n + 0.5 == k:
			break
		a = round(l / n)
	print(added)


(n, k) = map(int, input().split())
cur = sum(list(map(int, input().split())))
ans = 0
while round(cur / n + 1e-11) < k:
	cur += k
	n += 1
	ans += 1
print(ans)


def rg(n):
	return int(n) if n * 10 % 10 < 5 else int(n) + 1
(n, k) = map(int, input().split())
s = sum(map(int, input().split()))
c = 0
while rg(s / n) != k:
	s += k
	n += 1
	c += 1
print(c)


import sys, threading, os.path
import collections, heapq, math, bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('input.txt'):
		input = open('input.txt', 'r')
	else:
		input = sys.stdin
	(n, k) = list(map(int, input.readline().split()))
	lis = list(map(int, input.readline().split()))
	sum = 0
	for x in lis:
		sum += x
	if round(sum / n) >= k:
		output = 0
	else:
		count = n
		while True:
			if float(sum / count) >= float(k - 0.5):
				break
			sum += k
			count += 1
		output = count - n
	if os.path.exists('output.txt'):
		open('output.txt', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
M = int(S / float(n) + 0.5)
i = 0
while M < k:
	i += 1
	M = (S + i * k) / float(i + n)
	M = int(M + 0.5)
print(i)


import math

def solve():
	(n, k) = list((int(x) for x in input().split()))
	s = 0
	for x in input().split():
		s += int(x)
	for i in range(1000000):
		if s + i * k >= (k - 0.5) * (n + i):
			print(i)
			return

def main():
	solve()
	exit(0)
main()


import math
(n, k) = [int(x) for x in input().split()]
marks = [int(x) for x in input().split()]
marksSize = float(n)
notas = float(sum(marks))
grade = notas / float(n)
if grade - int(grade) == 0.5:
	grade = math.ceil(grade)
else:
	grade = round(grade)
if grade == k:
	graduated = True
else:
	graduated = False
	while graduated is False:
		notas += k
		marksSize += 1
		grade = notas / marksSize
		if grade - int(grade) == 0.5:
			grade = math.ceil(grade)
		else:
			grade = round(grade)
		if grade == k:
			graduated = True
print(int(marksSize - n))


def custom_round(n):
	return round(n) if n - int(n) != 0.5 else int(n) + 1
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
copy_n = n
s = sum(a)
while custom_round(s / n) < k:
	s += k
	n += 1
print(n - copy_n)


from functools import reduce
(n, k) = map(int, input().split())
mark = reduce(lambda x, y: x + y, [int(i) for i in input().split()][:n])
ctr = 0
mult = n
while mark / mult < k - 0.5:
	mark += k
	mult += 1
	ctr += 1
print(ctr)


import sys
(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
s = sum(marks)
av = s / n
cnt = 0
while k - av > 0.5:
	s += k
	n += 1
	cnt += 1
	av = s / n
print(cnt)


from decimal import Decimal
(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
sm = sum(marks)
ans = 0
while True:
	if sm / (n + ans) >= k - 0.5:
		break
	sm += k
	ans += 1
print(ans)


(n, k) = map(int, input().strip().split())
a = [int(s) for s in input().strip().split()]
r = max(0, 2 * k * n - 2 * sum(a) - n)
print(r)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = sum(a)
i = 0
l = len(a)
while round(s / l + 1e-05) != k:
	i += 1
	s += k
	l += 1
print(i)


(n, k) = [int(x) for x in input().split()]
I = [int(x) for x in input().split()]
b = sum(I)
a = b / n
i = 0
while a < k - 0.5:
	i = i + 1
	b = b + k
	a = b / (n + i)
print(i)


import sys, math, itertools, collections, bisect
input = lambda : sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10 ** 9 + 7
mans = inf
ans = 0
count = 0
pro = 1
(n, k) = map(int, input().split())
S = sum(map(int, input().split()))
print(max(0, n * k * 2 - n - 2 * S))


import math

def round(n):
	res = n % 1
	if res >= 0.5:
		return math.ceil(n)
	else:
		return math.floor(n)
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
s = sum(lst)
t = n
while round(s / t) != k:
	lst.append(k)
	s = sum(lst)
	t += 1
print(t - n)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = sum(l)
if a / n >= k - 0.5:
	print(0)
else:
	c = 0
	while a / n < k - 0.5:
		a = a + k
		n = n + 1
		c = c + 1
	print(c)


def ceil(n):
	int_n_plus_1 = int(n) + 1
	if n + 0.5 >= int_n_plus_1:
		return int_n_plus_1
	return int(n)
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
sum = sum(a)
for i in range(0, 1000007):
	num = len(a) + i
	new_sum = sum + i * k
	divide = new_sum / num
	if ceil(divide) >= k:
		print(i)
		break


import math
x = input()
x = x.split()
x = [int(i) for i in x]
l = input()
l = l.split()
l = [int(i) for i in l]
s = 0
for i in l:
	s += i
target = x[1]
n = len(l)
ct = n
fr = s / ct
while fr < target - 1 + 0.5:
	s += target
	ct += 1
	fr = s / ct
print(ct - n)


(a, b) = map(int, input().split())
t = list(map(int, input().split()))
k = sum(t)
t1 = k / a
if t1 + 0.5 > b:
	print(0)
else:
	print(int(2 * (a * b - a / 2 - k)))


from sys import maxsize, stdout, stdin, stderr
import re
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import ceil
(n, k) = tup()
ls = lint()
s = sum(ls)
cnt = 0
while s / n < k - 0.5:
	n += 1
	s += k
	cnt += 1
print(cnt)


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
(n, k) = rints()
a = rints()
sa = sum(a)
for i in range(20000):
	if (sa + i * k) / (n + i) >= k - 0.5:
		print(i)
		break


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)
add = 0
while (total + add * k) / (n + add) < k - 0.5:
	add += 1
print(add)


def main():
	s = k = n = x = 0
	(n, k) = map(int, input().split())
	for var in input().split():
		s += int(var)
	x = n * (k + k - 1) - (s + s)
	x = max(0, x)
	print(x)
	return
main()


def main():
	[n, k] = [int(_) for _ in input().split()]
	marks = [int(_) for _ in input().split()]
	s = sum(marks)
	if s * 2 >= n * (k * 2 - 1):
		print(0)
	else:
		print(2 * (n * k - s) - n)
main()


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = sum(a)
count = 0
flag = 0
e = d / len(a)
if k - e <= 0.5:
	print(0)
else:
	while k - e > 0.5:
		a.append(k)
		count = count + 1
		d = sum(a)
		e = d / len(a)
		if k - e <= 0.5:
			flag = 1
			break
if flag == 1:
	print(count)


(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
num = sum(marks)
num = 2 * (n * k - num)
if num > n:
	print(num - n)
else:
	print(0)


a = [int(j) for j in input().split()]
b = [int(j) for j in input().split()]
c = sum(b)
if c >= a[0] * (a[1] - 0.5):
	print(0)
else:
	print(a[0] * 2 * a[1] - a[0] - 2 * c)


def solve(arr, n, k):
	s = sum(arr)
	if round(s / n) == k:
		return 0
	count = 0
	while True:
		if (s + count * k) / (n + count) == k - 0.5:
			return count
		count += 1

def main():
	vars = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	print(solve(arr, *vars))
main()


(n, goal) = map(int, input().split())
marks = sum(list(map(int, input().split())))
num = n
while marks / num < float(goal) - 0.5:
	num += 1
	marks += goal
print(num - n)


(n, k) = map(int, input().split())
marks = list(map(int, input().split()))
summa = sum(marks)
nums = len(marks)
result = summa / nums
howmany = 0
while result < k - 0.5:
	summa += k
	nums += 1
	result = summa / nums
	howmany += 1
print(howmany)


import math
from functools import reduce

def ro(a):
	k = a - int(a)
	if k >= 0.5:
		return math.ceil(a)
	return math.floor(a)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = reduce(lambda x, y: x + y, a)
c = 0
while ro(a / n) < k:
	a += k
	n += 1
	c += 1
print(c)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
suma = sum(a)
if 2 * (k * n - suma) - n > 0:
	print(2 * (k * n - suma) - n)
else:
	print(0)


(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
sum1 = sum(arr)
k = k - 0.5
value = k * n - sum1
if int(2 * value) < 0:
	print(0)
else:
	print(int(2 * value))


(n, k) = [int(c) for c in input().split()]
_sum = sum((int(c) for c in input().split()))
ans = 0
while int(_sum / n + 0.5) < k:
	_sum += k
	n += 1
	ans += 1
print(ans)


import sys
(n, k) = map(int, sys.stdin.readline().rstrip().split())
l = list(map(int, sys.stdin.readline().rstrip().split()))
i = 0
while (sum(l) + k * i) / (i + n) < k - 0.5:
	i += 1
sys.stdout.write(str(i))


def excellent(lst, k):
	s = sum(lst)
	return max(0, (len(lst) * k - s) * 2 - len(lst))
(n, K) = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(excellent(a, K))


from math import ceil
(n, k) = [int(c) for c in input().split()]
s = sum((int(c) for c in input().split()))
print(max(0, ceil(2 * (n * (k - 0.5) - s))))


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
print(max(0, 2 * n * k - 2 * sum(a) - n))


R = lambda : list(map(int, input().split()))
(n, k) = R()
a = R()
s = sum(a)
l = len(a)
b = 0
while (s + l // 2) // l < k:
	s += k
	l += 1
	b += 1
print(b)


def roun(x):
	if x - int(x) < 0.5:
		return int(x)
	else:
		return int(x) + 1
(n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
list1 = list(map(int, input().strip().split(' ')))
su = sum(list1)
i = 0
while roun((k * i + sum(list1)) / (n + i)) < k:
	i += 1
if roun((k * i + sum(list1)) / (n + i)) == k:
	print(i)


(n, k) = map(int, input().split())
su = sum(map(int, input().split()))
ans = 0
while round(su / n + 1e-06) < k:
	su += k
	n += 1
	ans += 1
print(ans)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
answer = max(0, int(math.ceil(2 * n * k - 2 * s - n)))
print(answer)


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
(n, k) = map(int, input().split())
tot = sum([x for x in map(int, input().split())])
_k = k - 0.5
x = (_k * n - tot) / (k - _k)
print(int(x)) if int(x) > 0 else print(0)


def set_marks(max_mark, marks):
	sm = sum(marks)
	lm = len(marks)
	s = sm / lm
	if s >= max_mark - 0.5:
		return 0
	else:
		i = 0
		while s < max_mark - 0.5:
			sm += max_mark
			i += 1
			lm += 1
			s = sm / lm
		return i
(n, k) = map(int, input().split())
mrks = list(map(int, input().split()))
print(set_marks(k, mrks))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sm = sum(a)
(l, r) = (-1, 10 ** 20)

def check(m):
	return round((sm + k * m) / (n + m) + 1e-06) >= k
while r - l > 1:
	m = (l + r) // 2
	if check(m):
		r = m
	else:
		l = m
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
j = 0
if sum(a) / n >= k - 0.5:
	print(0)
	exit()
for i in range(1, 100001):
	l = (sum(a) + k * i) / (n + i)
	j += 1
	if l >= k - 0.5:
		break
print(j)


def roundoff(k):
	if k - int(k) < 0.5:
		return int(k)
	else:
		return int(k) + 1
(n, k) = map(int, input().strip().split()[:2])
l = list(map(int, input().strip().split()[:n]))
x = 0
s = sum(l)
p = s
while roundoff(p / (n + x)) != k:
	x += 1
	p = s + k * x
print(x)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
summ = 0
count = a[0]
for i in range(a[0]):
	summ += b[i]
while float(summ / count) + 0.5 < a[1]:
	summ += a[1]
	count += 1
print(count - a[0])


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
S = sum(L)
FLAG = 1
count = 0
while FLAG:
	if S / n + 0.5 >= k:
		FLAG = 0
		break
	count += 1
	S = S + k
	n = n + 1
print(count)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = sum(l)
r = s / n
if r >= k - 0.5:
	print(0)
else:
	x = n
	c = 0
	for i in range(100000):
		s = s + k
		x = x + 1
		c = c + 1
		if s / x >= k - 0.5:
			print(c)
			break


I = lambda : map(int, input().split())
(n, k) = I()
print(max(0, n * (2 * k - 1) - 2 * sum(I())))


(n, k) = input().split()
n = int(n)
k = int(k)
num = input().split()
num = list(map(int, num))
j = 0
s = sum(num)
while s / n < k - 0.5:
	s = s + k
	n = n + 1
	j = j + 1
print(j)


from math import ceil
(k, a) = [int(i) for i in input().split()]
print(max(0, ceil(2 * k * (a - 0.5) - 2 * sum([int(i) for i in input().split()]))))


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sum(a)
x = 0
i = 0
while k - a / (n + x) > 0.5:
	i += 1
	a += k * i
	x += i
	if k - a / (n + x) <= 0.5:
		a -= k * i
		x -= i
		break
while k - a / (n + x) > 0.5:
	a += k
	x += 1
print(x)