You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it:  Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$). 

You want to make the median of the array the largest possible using at most $k$ operations.

The median of the odd-sized array is the middle element after the array is sorted in non-decreasing order. For example, the median of the array $[1, 5, 2, 3, 5]$ is $3$.


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5$, $n$ is odd, $1 \le k \le 10^9$) — the number of elements in the array and the largest number of operations you can make.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$).


-----Output-----

Print a single integer — the maximum possible median after the operations.


-----Examples-----
Input
3 2
1 3 5

Output
5
Input
5 5
1 2 1 1 1

Output
3
Input
7 7
4 1 2 4 3 4 4

Output
5


-----Note-----

In the first example, you can increase the second element twice. Than array will be $[1, 5, 5]$ and it's median is $5$.

In the second example, it is optimal to increase the second number and than increase third and fifth. This way the answer is $3$.

In the third example, you can make four operations: increase first, fourth, sixth, seventh element. This way the array will be $[5, 1, 2, 5, 3, 5, 5]$ and the median will be $5$.

Difficulty: MEDIUM
Tags: Sorting

Mathematics

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
(n, m) = map(int, input().split())
lis = sorted(map(int, input().split()))
ind = n // 2
mid = lis[ind]
i = ind + 1
c = 1
while m > 0 and i < n:
	k = lis[i] - mid
	if k == 0:
		c += 1
	else:
		aa = min(m // c, k)
		m -= aa * c
		mid += aa
		c += 1
	i += 1
mid += m // (ind + 1)
print(mid)


(n, k) = map(int, input().split())
arr = sorted(list(map(int, input().split())))
mid = n // 2
q = 1
i = 0
ans = arr[mid]
while mid + 1 < n:
	for i in arr[mid + 1:]:
		if i != ans:
			break
		q += 1
		mid += 1
	if k - q * (i - ans) < 0:
		break
	k = k - q * (i - ans)
	ans = i
if k > 0 and k // q:
	ans = ans + k // q
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
s = 0
c = 1
v = []
for i in range(n // 2 + 1, n):
	v.append(c * (l[i] - l[i - 1]))
	c += 1
ans = 0
for i in range(len(v)):
	if k > 0 and v[i] > 0:
		m = min(v[i], k)
		ans += m // (i + 1)
		k -= m
if k > 0:
	ans += k // (len(v) + 1)
print(ans + l[n // 2])


def max_median(n, m, lst):
	(j, r) = (n // 2, n // 2 + 1)
	while m and r < n:
		if lst[j] == lst[r]:
			r += 1
		else:
			t = min(m, (lst[r] - lst[j]) * (r - j))
			lst[j] += t // (r - j)
			m -= t
	if lst[j] == lst[n - 1]:
		return lst[j] + m // (n - j)
	return lst[j] + min(m, (lst[r] - lst[j]) * (r - j)) // (r - j)
(N, K) = [int(i) for i in input().split()]
a = [int(x) for x in input().split()]
print(max_median(N, K, sorted(a)))


import sys
(n, k) = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
if n == 1:
	print(k + data[0])
	sys.exit()
data.sort()
data = data[n // 2:]
n = n // 2 + 1
sumto = [data[0]]
for i in range(1, n):
	sumto.append(sumto[-1] + data[i])
ans = n - 1
for i in range(1, n):
	am = i * data[i] - sumto[i - 1]
	if am > k:
		ans = i - 1
		break
am = ans * data[ans] - sumto[ans - 1]
if ans == 0:
	am = 0
left = k - am
extra = left // (ans + 1)
print(data[ans] + extra)


import sys
import os

def f(val, m, a, n):
	ret = 0
	for i in range(m, n):
		ret += max(0, val - a[i])
	return ret

def main():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a.sort()
	m = n // 2
	left = a[m]
	right = a[m] + k
	while left <= right:
		mid = left + (right - left) // 2
		if f(mid, m, a, n) <= k:
			best = mid
			left = mid + 1
		else:
			right = mid - 1
	print(best)
main()


(n, k) = list(map(int, input().split()))
numeros = list(map(int, input().split()))
numeros.sort()
centro = int(n / 2)
izq = numeros[centro]
der = 10000000000
while izq < der:
	medio = int((izq + der + 1) / 2)
	faltante = 0
	for i in range(centro, n, 1):
		if numeros[i] < medio:
			faltante += medio - numeros[i]
		else:
			break
	if faltante > k:
		der = medio - 1
	else:
		izq = medio
print(izq)


def find(A, K):
	A = sorted(A)

	def findout(target, K):
		want = 0
		for x in A:
			want += max(0, target - x)
		if want <= K:
			return True
		return False
	A = A[len(A) // 2:]
	left = min(A)
	right = left + K + 1
	while right - left > 1:
		mid = (left + right) // 2
		if findout(mid, K):
			left = mid
		else:
			right = mid
	if findout(left + 1, K):
		return left + 1
	else:
		return left
(n, k) = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
print(find(A, k))


(n, k) = map(int, input().split())
a = [int(o) for o in input().split()]
d = []
a = sorted(a)
lol = n // 2
i = n // 2
cv = a[lol]
while i < n:
	try:
		d.append([d[-1][0] + (a[i] - cv) * (i - lol), a[i], i])
	except:
		d.append([(a[i] - cv) * (i - lol), a[i], i])
	cv = a[i]
	if d[-1][0] > k:
		ans = d[-2][1] + (k - d[-2][0]) // (d[-2][2] - lol + 1)
		break
	if i == n - 1:
		ans = d[-1][1] + (k - d[-1][0]) // (d[-1][2] - lol + 1)
		break
	i += 1
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
(lo, hi) = (1, 999999999999)
while lo < hi:
	mid = (lo + hi) // 2
	tmp = 0
	for i in range(n // 2, n):
		tmp += max(mid - l[i], 0)
	if tmp <= k:
		lo = mid
	else:
		hi = mid - 1
	if hi - lo == 1:
		tmp = 0
		for i in range(n // 2, n):
			tmp += max(hi - l[i], 0)
		if tmp <= k:
			lo = hi
		else:
			hi = lo
print(lo)


(length, moves) = [int(x) for x in input().split()]
inp = [int(x) for x in input().split()]
middle = int((length + 1) / 2)
ans = int()
sameind = 0
counter = 0
inp.sort()
while moves > sameind:
	for i in range(middle + sameind, length):
		if inp[i] == inp[middle + sameind - 1]:
			sameind += 1
	if middle + sameind < length:
		nextdiff = inp[middle + sameind] - inp[middle + sameind - 1]
		if (sameind + 1) * nextdiff <= moves:
			moves -= (sameind + 1) * nextdiff
			counter += nextdiff
		else:
			counter += int(moves / (sameind + 1))
			moves -= (sameind + 1) * int(moves / (sameind + 1))
	else:
		counter += int(moves / (sameind + 1))
		moves -= (sameind + 1) * int(moves / (sameind + 1))
	sameind += 1
print(counter + inp[middle - 1])


from sys import stdin
input = stdin.readline
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))[n // 2:]
f = 1
i = 1
while k != 0 and i < len(a):
	r = a[i] - a[0]
	if r == 0:
		f += 1
		i += 1
		continue
	if f * r <= k:
		a[0] += r
		k -= r * f
	else:
		a[0] += k // f
		k = 0
	f += 1
	i += 1
print(a[0] + k // len(a))


(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
n1 = n // 2
count = 1
ans = a[n1]
for i in range(n1 + 1, n):
	if (a[i] - ans) * count <= m:
		m -= (a[i] - ans) * count
		ans = a[i]
	else:
		break
	count += 1
print(ans + m // count)


(n, k) = map(int, input().split())
numbers = [int(i) for i in input().split()]
numbers.sort()
l = numbers[0]
r = numbers[-1] + k
m = n // 2
while l <= r:
	mid = (l + r) // 2
	tmp = 0
	for i in numbers[m:]:
		if i < mid:
			tmp += mid - i
		else:
			break
	if tmp <= k:
		l = mid + 1
	else:
		r = mid - 1
print(l - 1)


(n, k) = input().split()
n = int(n)
k = int(k)
w = input().split()
w = [int(i) for i in w]
if n == 1:
	print(w[0] + k)
else:
	w = sorted(w)
	idx = len(w) // 2 + 1
	mul = 1
	gain = 0
	for i in range(idx - 1, len(w) - 1):
		d = w[i + 1] - w[i]
		if k > d * mul:
			k = k - d * mul
			gain += d
		else:
			gain += k // mul
			k = k - d * mul
			break
		mul += 1
	if k > 0:
		gain += k // mul
	print(w[idx - 1] + gain)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
curr = arr[n // 2]
count = 1
for i in range(n // 2 + 1, n):
	diff = arr[i] - curr
	if diff and diff * count <= k:
		k -= diff * count
		curr += diff
	elif diff and diff * count > k:
		curr += k // count
		k = 0
		break
	count += 1
curr = curr + k // ((n + 1) // 2)
print(curr)


ans = 0
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

def binarysearch(l: int, r: int):
	global ans
	while l <= r:
		mid = (l + r) // 2
		sum = 0
		for i in range(n // 2, n):
			sum += max(0, mid - a[i])
		if sum <= k:
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
a.sort()
binarysearch(0, a[n // 2] + k)
print(ans)


n_k = input()
n_k = n_k.split()
n = int(n_k[0])
k = int(n_k[1])
A = input()
A = A.split()
i = 0
while i < n:
	A[i] = int(A[i])
	i = i + 1
A.sort()
p = int(n / 2)
i = 0
lim = int(n / 2) + 1
result = A[p]
path = 0
while p < n:
	m = 1
	while p + 1 < n and A[p + 1] == A[p]:
		p = p + 1
		m = m + 1
	path = path + m
	p = p + 1
	z = int(k / path)
	if p < n:
		d = A[p] - A[p - 1]
		if z >= d:
			k = k - d * path
			result = result + d
		elif z == 0:
			break
		else:
			k = k - z * path
			result = result + z
	elif p == n:
		result = result + z
print(result)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = n // 2
p = m
l = a[p]
while True:
	if p < n - 1:
		if l < a[p + 1]:
			if k < p - m + 1:
				print(l)
				exit()
			k -= p - m + 1
			l += 1
		else:
			p += 1
	else:
		print(l + k // (p - m + 1))
		exit()


import math
(N, K) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
mIdx = math.floor(len(arr) / 2)
l = arr[mIdx]
r = 2000000000
while l < r:
	maybeAnswer = math.ceil((l + r) / 2)
	rem = K
	for i in range(mIdx, len(arr)):
		rem -= max(0, maybeAnswer - arr[i])
	if rem < 0:
		r = maybeAnswer - 1
	else:
		l = maybeAnswer
print(l)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = n // 2
l = 1
r = int(10000000000.0)
while l < r:
	m = (l + r + 1) // 2
	cnt = 0
	for i in range(s, n):
		cnt += max(0, m - a[i])
	if cnt <= k:
		l = m
	else:
		r = m - 1
print(l)


(n, k) = map(int, input().split())
a = sorted([int(x) for x in input().split()])[int(n / 2):]
n = len(a)
l = a[0]
h = a[n - 1] + k // n
ans = 0

def find(m):
	moves = 0
	for i in range(n):
		if m - a[i] > 0:
			moves += m - a[i]
		if moves > k:
			return False
	if moves > k:
		return False
	return True
while l <= h:
	m = (l + h) // 2
	if find(m):
		ans = max(ans, m)
		l = m + 1
	else:
		h = m - 1
print(ans)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
n //= 2
arr = arr[n:]
n += 1
med = arr[0]
flag = 1
while flag < n:
	if arr[flag] > med:
		kk = (arr[flag] - med) * flag
		if kk < k:
			k -= kk
			med = arr[flag]
		else:
			med += k // flag
			k = 0
			break
	flag += 1
if flag == n:
	med += k // flag
print(med)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
s = 0
for i in a[n // 2:]:
	s += m - i
if s <= k:
	ma = (sum(a[n // 2:]) + k) // (1 + n // 2)
	print(ma)
else:
	a = a[n // 2:]
	s = 0
	li = 0
	for i in range(len(a) - 1):
		if (a[i + 1] - a[i]) * (i + 1) + s > k:
			li = i
			break
		s += (a[i + 1] - a[i]) * (i + 1)
	print(((li + 1) * a[li] + (k - s)) // (1 + li))


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
arr = arr[n // 2:]
mid = arr[0]
start = mid
end = mid + k
while start < end:
	op = k
	f = 0
	med = (end + start + 1) // 2
	for i in range(len(arr)):
		if arr[i] < med:
			op -= med - arr[i]
		if op < 0:
			f = 1
			break
	if f == 1:
		end = med - 1
	else:
		start = med
print(start)


I = lambda : map(int, input().split())
(n, k) = I()
a = sorted(I())
(q, w, z) = (n // 2, 1, a[n // 2])
for i in range(q, n - 1):
	t = (a[i + 1] - a[i]) * w
	if k >= t:
		k -= t
		z = a[i + 1]
		w += 1
	else:
		break
print(z + k // w)


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

def valid(m):
	c = 0
	for i in range(n // 2, n):
		c += max(0, m - arr[i])
		if c > k:
			return False
	return True
(l, r) = (0, int(2000000000.0 + 3))
while l < r:
	m = l + r >> 1
	if valid(m):
		l = m + 1
	else:
		r = m - 1
if not valid(l):
	l -= 1
print(l)


(n, k) = map(int, input().split())
x = sorted(map(int, input().split()))[n // 2:]
r = x[0]
for i in range(1, len(x)):
	if i * (x[i] - r) <= k:
		k -= i * (x[i] - r)
		r = x[i]
	else:
		r += k // i
		break
else:
	r += k // len(x)
print(r)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
start_index = n // 2
cur_index = start_index
m = a[start_index]
numbers_to_inc_count = 1
while k != 0:
	if cur_index == n - 1:
		m += k // numbers_to_inc_count
		k = 0
	elif (a[cur_index + 1] - m) * numbers_to_inc_count <= k:
		k -= (a[cur_index + 1] - m) * numbers_to_inc_count
		m = a[cur_index + 1]
		cur_index += 1
		numbers_to_inc_count += 1
	else:
		m += k // numbers_to_inc_count
		k = 0
print(m)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
med = a[n // 2]
low = med
high = 2 * 10 ** 9 + 1
while low + 1 < high:
	mid = (low + high) // 2
	total = 0
	for el in a[n // 2:]:
		if el < mid:
			total += mid - el
	if total > k:
		(low, high) = (low, mid)
	else:
		(low, high) = (mid, high)
print(low)


def get_from_str(string: str):
	return list(map(int, string.split(' ')))

def test(string: str):
	(param, data) = string.split('\n')
	(n, k) = get_from_str(param)
	numbers = get_from_str(data)
	compute(n, k, numbers)

def sort_numbers(list_of_numbers):
	return sorted(list_of_numbers)

def find_bigger(numbers):
	first = numbers[0]
	if numbers[-1] == first:
		return False
	if numbers[1] > first:
		return 1
	left = 0
	right = len(numbers)
	while right - left > 1:
		center = (right + left) // 2
		if numbers[center] > numbers[left]:
			right = center
		else:
			left = center
	if numbers[left] > first:
		return left
	else:
		return right

def find_valid_area(numbers, k):
	first = numbers[0]
	if numbers[-1] == first:
		return k // len(numbers)
	left = 0
	right = len(numbers)
	center = 0
	while right - left > 1:
		center = (right + left) // 2
		height = numbers[center]
		area = height * center - sum(numbers[:center])
		if area > k:
			right = center
		else:
			left = center
	return (k + sum(numbers[:right])) // len(numbers[:right])

def compute(n, k, numbers):
	part_1 = sort_numbers(numbers)
	part_2 = part_1[n // 2:]
	part_3 = [item - part_2[0] for item in part_2]
	inc = find_valid_area(part_3, k)
	med = part_2[0] + inc
	print(med)
(n_gl, k_gl) = get_from_str(input())
numbers_gl = get_from_str(input())
compute(n_gl, k_gl, numbers_gl)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	(n, k) = read()
	arr = read()
	arr.sort()
	arr2 = arr[n // 2:]
	for i in range(1, len(arr2)):
		arr2[i] += arr2[i - 1]

	def chk(x):
		ind = bisect(arr[n // 2:], x) - 1
		return x * (ind + 1) - arr2[ind]
	(lo, hi) = (arr[n // 2], 10 ** 9 * 2)
	last = 0
	while lo <= hi:
		mid = (lo + hi) // 2
		if chk(mid) <= k:
			last = mid
			lo = mid + 1
		else:
			hi = mid - 1
	print(last)
solve()


def fun(X):
	Moves = 0
	for i in range(int(N // 2), N):
		if X - List[i] > 0:
			Moves += X - List[i]
		if Moves > K:
			return False
	return True
(N, K) = map(int, input().split())
List = [int(x) for x in input().split()]
List.sort()
Big = 2 * 10 ** 9
Small = 0
while Small != Big:
	mid = (Small + Big + 1) // 2
	if fun(mid):
		Small = mid
	else:
		Big = mid - 1
print(Small)


(n, k) = [int(s) for s in input().split()]
arr = sorted([int(s) for s in input().split()])
arr = arr[::-1]
arr = [pow(10, 11)] + arr[0:n // 2 + 1]
n = len(arr)
point = n - 1
while k != 0:
	t = min(k, (n - point) * (arr[point - 1] - arr[point]))
	k -= t
	arr[point] += t // (n - point)
	if k != 0:
		point -= 1
print(arr[point])


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
from itertools import accumulate as ac
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = 1
for _ in range(t):
	(n, k) = inp()
	arr = list(inp())
	arr.sort()
	arr = arr[n // 2:]
	ct = 1
	arr = deque(arr)
	while len(arr) != 1:
		if arr[0] == arr[1]:
			ct += 1
			arr.popleft()
		else:
			diff = arr[1] - arr[0]
			if k >= diff * ct:
				k -= ct * diff
				ct += 1
				arr.popleft()
			else:
				break
	add = k // ct
	ans = arr[0] + add
	print(ans)


input1 = input()
(n, k) = input1.split(' ')
n = int(n)
k = int(k)
input2 = input()
a = input2.split(' ')
for t in range(n):
	a[t] = int(a[t])
if len(a) == 1:
	print(a[0] + k)
else:
	a.sort()
	mid = int((n - 1) / 2)
	c = mid
	diff = []
	if a[mid + 1] - a[mid] >= k:
		print(a[mid] + k)
	else:
		len = mid
		copyk = k
		flag = 1
		copyt = 0
		for t in range(len):
			copykprev = copyk
			copyk = copyk - (a[t + mid + 1] - a[t + mid]) * (t + 1)
			if copyk <= 0:
				flag = 0
				copyt = t + mid
				break
		if flag == 1:
			ans = a[n - 1] + int(copyk / (n - mid))
			print(ans)
		else:
			print(a[copyt] + int(copykprev / (t + 1)))


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()

def actually_ok(l, m, kk):
	k = kk
	for i in range(len(l) - 1, int(n / 2) - 1, -1):
		if l[i] > m:
			return False
		k -= m - l[i]
	if k < 0:
		return False
	else:
		return True

def ok(l, m, kk):
	k = kk
	for i in range(len(l) - 1, int(n / 2) - 1, -1):
		k -= max(m - l[i], 0)
	if k < 0:
		return False
	else:
		return True
left = l[int(n / 2)]
right = l[int(n / 2)] + k
mid = (left + right) / 2
while right - left > 1:
	mid = int((left + right) / 2)
	if ok(l, mid, k):
		left = mid
	else:
		right = mid
if ok(l, right, k):
	print(right)
else:
	print(left)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for __ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	fr = n // 2
	ans = l[n // 2]
	for i in range(n // 2, n - 1):
		if l[i] != l[i + 1]:
			diff = (l[i + 1] - l[i]) * (i - fr + 1)
			if diff <= k:
				k -= diff
				ans = l[i + 1]
			else:
				ans += mt.floor(k / (i - fr + 1))
				k = 0
	k1 = mt.floor(k / (n - fr))
	ans += k1
	print(ans)


(n, k) = map(int, input().split())
array = list(map(int, input().split()))
array.sort()
med = n // 2

def key(m):
	s = 10 ** 10
	ind = None
	for i in range(n):
		if 0 <= m - array[i] <= s:
			s = m - array[i]
			ind = i
	if ind == None:
		return False
	if ind < med:
		return False
	else:
		for i in range(ind - 1, med - 1, -1):
			s += m - array[i]
		return s <= k
left = array[med]
right = 10 ** 10
while right - left != 1:
	mid = (right + left) // 2
	if key(mid):
		left = mid
	else:
		right = mid
print(left)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
N = 1000001
p = 10 ** 9 + 7
fact = [None] * (N + 1)
fact[0] = 1
for i in range(1, N + 1):
	fact[i] = fact[i - 1] * i % p

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		(n, k) = ria()
		a = ria()
		a = sorted(a)
		mid = n // 2
		i = 1
		c = 1
		ans = a[mid]
		while i + mid < n:
			z = (a[mid + i] - ans) * i
			if k - z >= 0:
				k -= z
				ans = a[mid + i]
				c += 1
			else:
				break
			i += 1
		ans += k // c
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


R = lambda : map(int, input().split())
(n, k) = R()
a = sorted(R())[n // 2:]
i = 0
for (x, y) in zip(a, a[1:] + [1 << 31]):
	i += 1
	d = min(y - x, k // i)
	a[0] += d
	k -= d * i
print(a[0])


(n, k) = map(int, input().split())
lst = sorted(list(map(int, input().split())))
middle = lst[n // 2]
if len(lst) == 1:
	print(middle + k)
	exit()
r = n // 2 + 1
while k > 0:
	while r < n and lst[r] == middle:
		r += 1
	if r == n:
		middle += k // (r - n // 2)
		k = 0
	else:
		put = lst[r] - middle
		if put * (r - n // 2) >= k:
			middle += k // (r - n // 2)
			k = 0
		else:
			middle += put
			k -= put * (r - n // 2)
print(middle)


from sys import stdin

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
(n, k) = lin()
a = lin()
if n == 1:
	print(a[0] + k)
else:
	a.sort()
	h = n // 2
	ch1 = 0
	ch2 = h + 1
	for i in range(h + 1, n):
		if (a[i] - a[i - 1]) * (i - h) <= k:
			mn = (a[i] - a[i - 1]) * (i - h)
			k -= mn
		else:
			ch1 = 1
			ch2 = i
			for j in range(h, i):
				a[j] = a[i - 1]
			break
	else:
		for j in range(h, n):
			a[j] = a[-1]
	rng = h + 1
	if ch1:
		rng = ch2 - h
	su = k // rng
	if su:
		for i in range(h, h + rng):
			a[i] += su
	for i in range(k % rng):
		a[h + i] += 1
	a.sort()
	print(a[h])


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))[n // 2:]
f = 1
i = 1
while k != 0 and i < len(a):
	r = a[i] - a[0]
	if r == 0:
		f += 1
		i += 1
		continue
	if f * r <= k:
		a[0] += r
		k -= r * f
	else:
		a[0] += k // f
		k = 0
	f += 1
	i += 1
print(a[0] + k // len(a))


(n, k) = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
mid = n // 2
arr = data[mid:]
mid = arr[0]
for i in range(1, len(arr)):
	count = arr[i] - arr[i - 1]
	if k >= count * i:
		k -= count * i
		mid += count
	else:
		mid += k // i
		k = 0
if k:
	mid += k // len(arr)
print(mid)


import os
import sys
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a.sort()
	low = 0
	high = int(1000000000000000.0)
	middle = (n - 1) // 2

	def pos(midd):
		if midd <= a[middle]:
			return True
		else:
			temp = bl(a, midd)
			sm = 0
			for x in range(middle, temp):
				sm += a[x]
			return midd * (temp - middle) - sm <= k
	while low <= high:
		mid = (low + high) // 2
		if pos(mid) and pos(mid + 1) == False:
			break
		elif pos(mid):
			low = mid + 1
		else:
			high = mid - 1
	print(mid)
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')
main()


(n, k) = map(int, input().split())
s = sorted(list(map(int, input().split())))
s[0:n // 2] = []
med = 0
if n == 1:
	print(s[0] + k)
else:
	i = 0
	while k > (i + 1) * (s[i + 1] - s[i]):
		k = k - (i + 1) * (s[i + 1] - s[i])
		i += 1
		if i == n // 2:
			break
	med = s[i] + k // (i + 1)
	print(med)


from sys import stdin
(n, k) = (int(i) for i in stdin.readline().split())
arr = sorted((int(i) for i in stdin.readline().split()))
bot = arr[n // 2]
top = arr[-1]

def double(alpha, beta):
	if beta == alpha + 1:
		if limit(beta) > k:
			return alpha
		else:
			return beta
	middle = (alpha + beta) // 2
	A = limit(middle)
	if A > k:
		return double(alpha, middle)
	if A < k:
		return double(middle, beta)
	if A == k:
		return middle

def limit(mid):
	B = 0
	for i in arr[n // 2:]:
		if i >= mid:
			break
		B += mid - i
	return B
print(double(bot, top + k))


def do(arr, k):
	n = len(arr)
	arr = arr[n // 2:]
	n -= n // 2
	i = 0
	while k and i < n - 1:
		while i < n - 1 and arr[i + 1] == arr[i]:
			i += 1
		if i == n - 1:
			break
		if (arr[i + 1] - arr[i]) * (i + 1) <= k:
			k -= (arr[i + 1] - arr[i]) * (i + 1)
		else:
			return arr[i] + k // (i + 1)
		i += 1
	return arr[i] + k // (i + 1)
k = int(input().split()[1])
arr = list(map(int, input().split()))
print(do(sorted(arr), k))


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
t = n // 2
s = m
i = 1
k = 0
A.sort()
while t < n:
	s += A[t]
	k = s // i
	if t != n - 1 and k <= A[t + 1]:
		break
	t += 1
	i += 1
print(k)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = [0] * (n // 2)
m = n // 2
ans = a[m]
s = 0
for i in range(m + 1, n):
	p[i - m - 1] = a[i] - a[i - 1]
	s += p[i - m - 1] * (i - m)
if k < s:
	for i in range(m):
		r = p[i] * (i + 1)
		if k >= r:
			k -= r
			ans += p[i]
		else:
			ans += k // (i + 1)
			break
else:
	k -= s
	ans = a[-1]
	ans += k // (m + 1)
print(ans)


import math
from decimal import Decimal
import heapq

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
	print(a[0] + k)
	exit()
a = sorted(a)
d = n // 2 + 1
ans = a[d - 1]
kk = 1
for i in range(d, n):
	rz = a[i] - a[i - 1]
	if rz * kk <= k:
		dd = rz * kk
		k -= dd
		ans = a[i]
		kk += 1
	else:
		dd = k // kk
		ans += dd
		k = 0
		print(ans)
		exit()
if k > 0:
	dd = k // kk
	ans += dd
print(ans)


import sys
from math import *
import threading
from itertools import count
from pprint import pprint
from collections import defaultdict
from heapq import heapify, heappop, heappush
sys.setrecursionlimit(300000)
mod = 10 ** 9 + 7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'
import os
from io import BytesIO, IOBase
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')

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def check(median):
	s = 0
	for i in range(n // 2, n):
		s += median - a[i]
		if s > k:
			return False
	if s <= k:
		return True
karmanya = 0
for _ in range(int(input()) if karmanya else 1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	start = a[n // 2]
	end = a[n // 2] + k
	while start <= end:
		mid = (start + end) // 2
		if check(mid):
			start = mid + 1
		else:
			end = mid - 1
	print(end)


(n, k) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

def ok(x):
	mv = int(0)
	for i in range(n // 2, n):
		if x - a[i] > 0:
			mv += x - a[i]
		if mv > k:
			return False
	if mv <= k:
		return True
	else:
		return False
mx = 2000000000
mn = 1
while mn < mx:
	md = (mn + mx + 1) // 2
	if ok(md):
		mn = md
	else:
		mx = md - 1
print(mn)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq 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')

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()]

def can(x):
	operNeed = 0
	for i in range(n // 2, n):
		operNeed += max(0, x - a[i])
		if a[i] > x:
			x = a[i]
	return operNeed <= k
(n, k) = value()
a = sorted(array())
low = a[n // 2]
high = low + k
ans = low
while low <= high:
	mid = (low + high) // 2
	if can(mid):
		low = mid + 1
		ans = mid
	else:
		high = mid - 1
print(ans)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
data = data[n // 2:]
now = data[0]
cnt = 0
for i in data:
	if k - (i - now) * cnt >= 0:
		k -= (i - now) * cnt
	else:
		break
	now = i
	cnt += 1
if k > 0:
	now += k // cnt
print(now)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
med = a[n // 2:]
i = 0
mn = med[0]
for i in range(len(med) - 1):
	if k >= (i + 1) * (med[i + 1] - med[i]):
		k -= (i + 1) * (med[i + 1] - med[i])
		mn = med[i + 1]
	else:
		mn += k // (i + 1)
		k = 0
		break
mn += k // len(med)
print(mn)


(_, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
n = len(a) // 2
med = a[n]
klast = 1
while k > 0 and n + 1 < len(a):
	k1 = (a[n + 1] - a[n]) * klast
	if k >= k1:
		k -= k1
		med = a[n + 1]
	else:
		break
	n += 1
	klast += 1
if k > 0:
	med += k // klast
print(med)


def check(x):
	suma = 0
	for i in range(n // 2, n):
		suma += x - a[i]
		if suma > k:
			return False
	if suma <= k:
		return True
	return False
(n, k) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
a.sort()
l = 1
r = 2000000000
while l != r:
	mid = (l + r + 1) // 2
	if check(mid):
		l = mid
	else:
		r = mid - 1
print(l)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = n // 2
res = a[m]
elem = 1
a.append(10 ** 40)
for i in range(m, n):
	if (a[i + 1] - res) * elem > k:
		res += k // elem
		break
	else:
		k -= elem * (a[i + 1] - res)
		res = a[i + 1]
		elem += 1
print(res)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
a = a[len(a) // 2:]
m = 1
while m < len(a) and k - (a[m] - a[0]) * m >= 0:
	k -= (a[m] - a[0]) * m
	a[0] = a[m]
	m += 1
a[0] += k // m
print(a[0])


def binarySearch(arr, l, r, x):
	mid = int(l + (r - l) / 2)
	if r >= l:
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binarySearch(arr, l, mid - 1, x)
		else:
			return binarySearch(arr, mid + 1, r, x)
	else:
		return mid
(les, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
nums.sort()
nums = nums[les // 2:]
hbNum = 1
hbValue = nums[0]
del nums[0]
while k > 0:
	while len(nums) > 0 and hbValue == nums[0]:
		del nums[0]
		hbNum += 1
	try:
		taller = (nums[0] - hbValue) * hbNum
	except:
		taller = 'fuck'
	if taller != 'fuck' and k >= taller:
		hbValue = nums[0]
		k -= taller
	else:
		hbValue += k // hbNum
		k = 0
print(hbValue)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

def li():
	return list(map(int, input().split()))
(n, k) = mi()
d = sorted(li())
p = n // 2
mul = 1
r = d[p]
for i in range(p, n - 1):
	if k < (d[i + 1] - d[i]) * mul:
		break
	else:
		r = d[i + 1]
		k -= (d[i + 1] - d[i]) * mul
		mul += 1
print(r + k // mul)


def f(A, n, x, k):
	c = 0
	for i in range(n - 1, n // 2 - 1, -1):
		if A[i] < x:
			c = c + x - A[i]
	if c > k:
		return False
	else:
		return True
(n, k) = map(int, input().split())
a = input()
A = list(map(int, list(a.split())))
A.sort()
l = A[n // 2]
h = A[n // 2] + k
while l <= h:
	mid = (l + h) // 2
	if f(A, n, mid, k) == True and f(A, n, mid + 1, k) == False:
		print(mid)
		break
	elif f(A, n, mid, k) == False:
		h = mid - 1
	elif f(A, n, mid + 1, k) == True:
		l = mid + 1


(n, k) = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
med = len(a) // 2
look = med
extra = 0
idiff = 0
last = a[med]
while look < len(a) - 1:
	look += 1
	idiff += 1
	diff = a[look] - last
	last = a[look]
	chunk = idiff * diff
	if chunk <= k:
		k -= chunk
		extra += diff
	else:
		extra += k // idiff
		k = 0
if k > 0:
	extra += k // (idiff + 1)
print(a[med] + extra)


nk = input().split(' ')
(n, k) = (int(nk[0]), int(nk[1]))
a = list(map(int, input().split(' ')))
a.sort()
start = (n - 1) // 2
prev = 1
max_med = a[start]
for i in range(start + 1, n):
	required = (a[i] - a[i - 1]) * prev
	if k - required >= 0:
		k -= required
		prev += 1
		max_med = a[i]
	else:
		possible = k // prev
		max_med = a[i - 1] + possible
		k = 0
		break
if k != 0:
	max_med += k // prev
print(max_med)


import sys
input = sys.stdin.readline
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
l = sorted(l)
p = n // 2
ans = l[p]
tgt = 1
while p < n - 1:
	diff = l[p + 1] - l[p]
	if k >= diff * tgt:
		k -= diff * tgt
		p += 1
		ans = l[p]
		tgt += 1
	else:
		print(ans + k // tgt)
		return
print(ans + k // tgt)


def chk(m):
	f = 0
	for i in range(n // 2, n):
		if a[i] >= m:
			continue
		else:
			f += m - a[i]
	return f > k
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 0
r = 2 * 10 ** 9 + 1
while r - l > 1:
	m = (l + r) // 2
	if chk(m):
		r = m
	else:
		l = m
print(l)


(n, k) = (int(i) for i in input().split())
a = sorted([int(i) for i in input().split()])[n // 2:]
m = 0
for i in range(n - n // 2):
	if i * (a[i] - m) <= k:
		k -= i * (a[i] - m)
		m = a[i]
	else:
		i -= 1
		break
if k // (i + 1) > 0:
	m += k // (i + 1)
print(m)


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

def solver(v, p):
	for i in range(n // 2, n):
		if arr[i] <= v:
			t = v - arr[i]
			p = p - t
	if p >= 0:
		return True
	else:
		return False
start = 1
end = 10 ** 14
while end - start > 1:
	mid = (start + end) // 2
	if solver(mid, k) == True:
		start = mid
	else:
		end = mid
if solver(start, k) == True:
	print(start)
else:
	print(end)


import io, os
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
a.sort()
x = sorted(set(a[n // 2:]))
for i in range(n // 2, n):
	c = a[i]
	d[c] = d.get(c, 0) + 1
mid = a[n // 2]
kmid = d[mid]
i = 0
while k and kmid < n // 2 + 1:
	if k < kmid:
		k = 0
	elif k == kmid:
		mid += 1
		k = 0
	elif k < kmid * (x[i + 1] - x[i]):
		mid += k // kmid
		k = 0
	else:
		mid = x[i + 1]
		k -= kmid * (x[i + 1] - x[i])
		i += 1
		kmid += d[mid]
print(mid + k // kmid)


from sys import stdin, stdout
input = stdin.readline
t = 1
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a = sorted(a)
	val = 1
	for i in range(n // 2 + 1, n):
		diff = (a[i] - a[i - 1]) * val
		if diff <= k:
			k -= diff
		else:
			m = k // val
			ans = a[i - 1] + m
			break
		val += 1
	else:
		m = k // val
		ans = a[-1] + m
	print(ans)


def solve(a, n, k):
	if n == 1:
		return a[0] + k
	a.sort()
	total = sum(a[n // 2:]) + k
	avg = total // (n // 2 + 1)
	remain = total % (n // 2 + 1)
	element = n // 2 + 1
	for i in range(n - 1, n // 2 - 1, -1):
		if a[i] <= avg + remain and a[i - 1] <= avg:
			return avg
		else:
			total -= a[i]
			element -= 1
			avg = total // element
			remain = total % element
	return a[n // 2] + k
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(a, n, k))


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

def median(arr, k):
	arr.sort()
	n = (len(arr) - 1) // 2
	arr = arr[n:]
	while k > 0:
		m = arr.count(arr[0])
		if m == len(arr):
			return arr[0] + k // m
		x = arr[m]
		ecart = x - arr[0]
		if m * ecart <= k:
			arr = [x] * m + arr[m:]
			k -= m * ecart
		else:
			return arr[0] + k // m
	return arr[0]
print(median(l, k))


import sys
import math
from collections import deque, defaultdict
from string import ascii_letters
letters = ascii_letters[:26]
ONLINE_JUDGE = 0
if any(['--local' in i for i in sys.argv]) and (not ONLINE_JUDGE):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, k) = map(int, input().split())
arr = list(sorted(map(int, input().split())))[n // 2:]
n = len(arr)
res = arr[0]
for i in range(n - 1):
	delta = (arr[i + 1] - arr[i]) * (i + 1)
	if delta > k:
		res += k // (i + 1)
		k = 0
		break
	else:
		k -= delta
		res = arr[i + 1]
res += k // n
print(res)


fst = list(map(int, input().split()))
extra = fst[1]
numbers = sorted(list(map(int, input().split())))
i = len(numbers) // 2 + 1
possibleans = numbers[len(numbers) // 2] + extra
while i < len(numbers):
	if possibleans <= numbers[i]:
		break
	extra += numbers[i] - numbers[len(numbers) // 2]
	possibleans = numbers[len(numbers) // 2] + extra // (i + 1 - len(numbers) // 2)
	i += 1
print(min(possibleans, numbers[len(numbers) // 2] + fst[1]))


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
for i in range(n // 2, n - 1):
	if k >= (s[i + 1] - s[i]) * (i + 1 - n // 2):
		k -= (s[i + 1] - s[i]) * (i + 1 - n // 2)
	else:
		print(s[i] + k // (i + 1 - n // 2))
		break
else:
	print(s[-1] + k // (n - n // 2))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import log2, ceil
from bisect import bisect_right as br, bisect_left as bl
from collections import Counter as C
(n, k) = I()
l = I()
l.sort()
if n == 1:
	print(l[0] + k)
	exit()
m = l[n // 2]
l += [10 ** 18]
a = n // 2
for i in range(a, n + 1):
	if (i - a) * (l[i] - m) <= k:
		k -= (i - a) * (l[i] - m)
		m = l[i]
	else:
		print(m + k // (i - a))
		break


def check(x):
	ans1 = 0
	for i in range(n // 2, n):
		ans1 += max(0, x - arr[i])
	return ans1
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
l = 1
r = 2000000000
ans = 0
while l <= r:
	mid = (l + r) // 2
	if check(mid) <= k:
		ans = max(ans, mid)
		l = mid + 1
	else:
		r = mid - 1
print(ans)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
mid = n // 2
if n == 1:
	print(a[0] + k)
	exit()
t = k
k -= min(a[mid + 1] - a[mid], k)
if k == 0:
	print(a[mid] + t)
	exit()
a[mid] += a[mid + 1] - a[mid]
c = 1
for i in range(mid + 1, n):
	if a[i] == a[mid]:
		c += 1
	else:
		r = a[i] - a[mid]
		yy = r * c
		t = k
		k -= min(yy, k)
		if k == 0:
			a[mid] += t // c
		else:
			c += 1
			a[mid] = a[i]
if k != 0:
	a[mid] += k // c
print(a[mid])


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
st = n // 2
cur = arr[st]
cnt = 1
f = 0
for i in range(st + 1, n):
	diff = arr[i] - cur
	if diff * cnt <= k:
		k -= diff * cnt
		cnt += 1
		cur = arr[i]
	else:
		f = 1
		break
if f == 0:
	cur += k // (st + 1)
else:
	cur += k // cnt
print(cur)


from math import *
from collections import *
from itertools import *
from functools import *
from random import *

def getl(t=int):
	return [t(x) for x in input().split()]

def get(t=int):
	return t(input())
alphabet = [chr(x) for x in range(ord('a'), ord('z') + 1)]
alnum = lambda x: ord(x) - ord('a')

def main():
	(n, k) = getl()
	a = getl()
	a.sort()
	i = n // 2
	z = 1
	while i < n - 1 and k >= 0:
		k_old = k
		k -= (a[i + 1] - a[i]) * z
		if k < 0:
			print(a[i] + k_old // z)
			return
		else:
			i += 1
		z += 1
	print(a[n - 1] + k // (n // 2 + 1))
main()


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
x = len(a) // 2
rem = 1
ans = a[x]
while k > 0:
	if x + rem < len(a):
		if k >= rem * (a[x + rem] - a[x + rem - 1]):
			k -= rem * (a[x + rem] - a[x + rem - 1])
			ans = a[x + rem]
			rem += 1
		else:
			ans += k // rem
			k = 0
	else:
		ans += k // rem
		k = 0
print(ans)


import sys, os, re, datetime
from collections import *
from bisect import *

def mat(v, *dims):

	def submat(i):
		if i == len(dims) - 1:
			return [v for _ in range(dims[-1])]
		return [submat(i + 1) for _ in range(dims[i])]
	return submat(0)
__cin__ = None

def cin():
	try:
		global __cin__
		if __cin__ is None:
			__cin__ = iter(input().split(' '))
		try:
			return next(__cin__)
		except StopIteration:
			__cin__ = iter(input().split(' '))
			return next(__cin__)
	except EOFError:
		return None

def iarr(n):
	return [int(cin()) for _ in range(n)]

def farr(n):
	return [float(cin()) for _ in range(n)]

def sarr(n):
	return [cin() for _ in range(n)]

def carr(n):
	return input()

def imat(n, m):
	return [iarr(m) for _ in range(n)]

def fmat(n, m):
	return [farr(m) for _ in range(n)]

def smat(n, m):
	return [sarr(m) for _ in range(n)]

def cmat(n, m):
	return [input() for _ in range(n)]
n = int(cin())
k = int(cin())
a = iarr(n)
a.sort(key=lambda x: x)
r = []
i = n // 2
while i < n:
	v = a[i]
	j = i
	while j < n and a[j] == v:
		j += 1
	r.append([v, j - i])
	i = j
i = 0
while i + 1 < len(r):
	d = r[i + 1][0] - r[i][0]
	t = r[i][1]
	if d * t > k:
		break
	else:
		k = k - d * t
		r[i + 1][1] = r[i + 1][1] + r[i][1]
		i = i + 1
print(r[i][0] + k // r[i][1])


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


(n, k) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
l.sort()
mid = int((n - 1) / 2)
s = 0
mx = l[n - 1]
ans = -1

def check(start, end, l):
	mx = l[end]
	ret = 0
	for i in range(start, end):
		ret += mx - l[i]
	return ret
for i in range(mid, n - 1):
	s += mx - l[i]
if k >= s:
	k -= s
	ans = mx + k // (mid + 1)
else:
	r = n - 1
	le = mid
	while r - le > 1:
		m = (r + le) // 2
		if check(mid, m, l) <= k:
			le = int(m)
		else:
			r = int(m)
	last = -1
	if check(mid, r, l) <= k:
		last = r
	else:
		last = le
	k -= check(mid, last, l)
	num = last - mid + 1
	ans = l[last] + k // num
print(ans)


import typing

def maximum_median(a: typing.List[int], k: int) -> int:
	sorted_a = sorted(a)
	low = sorted_a[len(sorted_a) // 2]
	high = low + k
	result = -1
	while low <= high:
		mid = low + (high - low >> 1)
		ops = count_operations_to_get_median(sorted_a, mid)
		if ops > k:
			high = mid - 1
		elif ops <= k:
			result = mid
			low = mid + 1
	return result

def count_operations_to_get_median(sorted_a: typing.List[int], median: int) -> int:
	ops = 0
	middle_i = len(sorted_a) // 2
	for i in range(middle_i, len(sorted_a)):
		ops += max(0, median - sorted_a[i])
	return ops

def main():
	first_line = input().split()
	second_line = input().split()
	k = int(first_line[1])
	a = [int(a_i) for a_i in second_line]
	print(maximum_median(a, k))
main()


(n, k) = list(map(int, input().split()))
A = [int(x) for x in input().split()]
A.sort()
median = A[n // 2]
inf = 10 ** 16
from collections import defaultdict as dd, deque
C = dd(int)
for x in A[n // 2:]:
	C[x] += 1
C[inf] = 123
nmedian = C[median]
S = sorted(C.items())
i = 0
while i < len(S) and S[i][0] < median:
	i += 1
while True:
	(who, count) = S[i + 1]
	afford = k // nmedian
	if who != inf:
		can = who - median
	else:
		can = inf
	if min(afford, can) == can:
		k -= can * nmedian
		median = who
		nmedian += count
	else:
		median += afford
		break
	i += 1
print(median)


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
s.sort()
s = s[n // 2:]
low = s[0]
high = 2 * 10 ** 9

def can(x):
	ans = 0
	for i in range(len(s)):
		if s[i] < x:
			ans += x - s[i]
	if ans <= m:
		return True
	else:
		return False
while high - low > 1:
	mid = (high + low) // 2
	if can(mid):
		low = mid
	else:
		high = mid
if can(high):
	print(high)
else:
	print(low)


(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()

def bs(m):
	moves = abs(l[n // 2] - m)
	ma = m
	for i in range(n // 2 + 1, n):
		ma = max(l[i], ma)
		if l[i] < ma:
			moves += abs(l[i] - ma)
	if moves <= k:
		return True
	else:
		return False
if n == 1:
	print(l[0] + k)
else:
	(lo, hi) = (l[n // 2], max(l) + k)
	while lo <= hi:
		m = lo + (hi - lo) // 2
		if l[n // 2] >= m:
			lo = m + 1
		elif bs(m):
			ans = m
			lo = m + 1
		else:
			hi = m - 1
	print(lo - 1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
	print(arr[0] + k)
	exit(0)
arr.sort()
i = (n - 1) // 2
m = arr[i]
cnt = 1
i += 1
while i < n:
	nxt = arr[i]
	if k < (nxt - m) * cnt:
		print(m + k // cnt)
		exit(0)
	k -= (nxt - m) * cnt
	m = nxt
	cnt += 1
	i += 1
if k >= 0:
	print(m + k // cnt)


def int_multiple():
	return [int(c) for c in input().split()]

def int_single():
	return int(input())

def str_multiple():
	return [c for c in input().split()]

def str_single():
	return input()
(n, k) = int_multiple()
l = int_multiple()
l = sorted(l)
mid = int(n / 2)
l = l[mid:]
acc = []
r = 0
for i in range(len(l)):
	r += l[i]
	acc.append(r)
ans = 0
for i in reversed(range(len(l))):
	need = l[i] * (i + 1)
	hand = acc[i] + k
	if hand >= need:
		left = hand - need
		additional = int(left / (i + 1))
		ans = l[i] + additional
		break
print(ans)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
lena = len(A)
medInd = lena // 2
res = A[medInd]
count = 1
while k > 0:
	if count <= medInd:
		fin = A[medInd + count]
		if k < (fin - res) * count:
			res += k // count
			break
		else:
			k -= (fin - res) * count
			res = fin
			count += 1
	else:
		res += k // count
		break
print(res)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
medianIndex = n // 2
a = a[medianIndex:]
left = 1
right = 10 ** 10
while left < right:
	mid = (left + right + 1) // 2
	count = 0
	for i in range(len(a)):
		count += max(0, mid - a[i])
	if count > k:
		right = mid - 1
	else:
		left = mid
print(left)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
id = n // 2
for i in range(n // 2, n - 1):
	if (a[i + 1] - a[i]) * (i + 1 - id) > k:
		print(a[i] + k // (i + 1 - id))
		return
	else:
		k -= (a[i + 1] - a[i]) * (i + 1 - id)
print(a[-1] + k // (n - id))


(n, m) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
s.sort()
k = (n - 1) // 2
ind = k + 1
med = s[k]
while m >= 0:
	if ind == n:
		med += m // (ind - k)
		break
	m -= (s[ind] - med) * (ind - k)
	med = s[ind]
	ind += 1
if m < 0:
	ind -= 1
	med -= -m // (ind - k)
	if -m % (ind - k):
		med -= 1
print(med)


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, k) = get_ints()
	arr = get_list()
	arr.sort()
	x1 = 1
	x2 = 2000000000.0 + 1
	while x1 <= x2:
		m = (x1 + x2) // 2
		s = 0
		for i in range(n // 2, n):
			s += max(0, m - arr[i])
		if s <= k:
			ans = m
			x1 = m + 1
		else:
			x2 = m - 1
	print(int(ans))


(a, b) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
m = a // 2
s = 0
s += A[m]
k = 1
t = True
m += 1
while t == True and m < a:
	if A[m] * k - s >= b:
		t = False
	else:
		s += A[m]
		k += 1
		m += 1
q = A[m - 1] * k
v = q - s
b -= v
e = b // k
print(A[m - 1] + e)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
(ind, val) = (n // 2, 0)
(ans, ind1) = (a[ind], 1)
for i in range(ind + 1, n):
	val = (a[i] - a[i - 1]) * ind1
	if k - val >= 0:
		k -= val
		ind1 += 1
		ans = a[i]
	else:
		ans = a[i - 1] + k // ind1
		k = 0
		break
if k != 0:
	ans += k // ind1
print(ans)


import math
(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
n1 = n // 2
l = 0
r = 2 * 10 ** 9
while l < r:
	mid = (l + r + 1) // 2
	sum = 0
	for i in range(n1, n):
		sum += max(0, mid - a[i])
	if sum <= k:
		l = mid
	else:
		r = mid - 1
print(l)


import sys
(n, k) = [int(x) for x in input().split()]
lis = [int(x) for x in input().split()]
lis = sorted(lis)
middle_ind = n // 2
middle_value = lis[middle_ind]
for i in range(middle_ind, n - 1):
	if k - (lis[i + 1] - lis[i]) * (i - middle_ind + 1) < 0:
		print(lis[i] + k // (i - middle_ind + 1))
		sys.exit()
	k = k - (lis[i + 1] - lis[i]) * (i - middle_ind + 1)
print(lis[n - 1] + k // (middle_ind + 1))


(n, k) = list(map(int, input().split()))
ai = list(map(int, input().split()))
ai.sort()
num = n // 2
num2 = num
ans = ai[num]
n2 = n - 1
while num != n2 and k > 0:
	num += 1
	k -= (ai[num] - ai[num - 1]) * (num - num2)
if k < 0:
	print(ai[num] + k // (num - num2))
else:
	print(ai[num] + k // (num - num2 + 1))


(n, k) = [int(a) for a in input().split()]
a = list(map(int, input().split()))
m = n // 2
a.sort()
l = 1
r = int(2000000000.0)
while l != r:
	mid = (l + r + 1) // 2
	tmp = 0
	for i in range(m, n):
		if mid - a[i] > 0:
			tmp += mid - a[i]
		if tmp > k:
			r = mid - 1
	if tmp <= k:
		l = mid
print(l)


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

def check(m):
	c = 0
	for i in range(n // 2, n):
		if a[i] > m:
			break
		else:
			c += m - a[i]
	return c <= k
l = a[n // 2]
r = a[n // 2] + k + 1
while r - l > 1:
	m = (r + l) // 2
	if check(m):
		l = m
	else:
		r = m
print(l)


from sys import *
from math import *
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
a.sort()
m = n // 2
j = 1
for i in range(m + 1, n):
	d = a[i] - a[m]
	if k - j * d >= 0:
		a[m] += d
		k -= j * d
		j += 1
	else:
		break
a[m] += k // j
print(a[m])


(a, b) = map(int, input().split())
l = list(map(int, input().split()))[:a]
l.sort()
c = 1
ans = l[a // 2]
for i in range(a // 2 + 1, a):
	if c * (l[i] - ans) <= b:
		b -= c * (l[i] - ans)
		ans = l[i]
	else:
		break
	c += 1
print(ans + b // c)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
index = a // 2 + 1
count = 1
while b > 0:
	if index == a:
		l[a // 2] += b // (a // 2 + 1)
		break
	diff = l[index] - l[a // 2]
	if count * diff <= b:
		b -= count * diff
		count += 1
		index += 1
		l[a // 2] += diff
	else:
		l[a // 2] += b // count
		break
print(l[a // 2])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = a[n // 2]
p = 1
q = n // 2 + 1
e = True
t = True
if n == 1:
	m += k
	k = 0
	q = 0
while a[q] == m:
	p += 1
	q += 1
	if q == n:
		q -= 1
		e = False
		break
if e == False:
	m += k // p
	k = 0
while k > 0:
	if k - (a[q] - m) * p < 0:
		t = False
		break
	k -= (a[q] - m) * p
	m = a[q]
	while a[q] == m:
		p += 1
		q += 1
		if q == n:
			q -= 1
			e = False
			break
	if e == False:
		if k > 0:
			m += k // p
			k = 0
		break
if t == False:
	m += k // p
print(m)


(n, k) = map(int, input().split())
S = list(map(int, input().split()))
S.sort()
S = S[n // 2:]
ind = 0
while True:
	if ind == n // 2 or k < ind + 1:
		print(S[ind] + k // (n // 2 + 1))
		break
	else:
		if S[ind] == S[ind + 1]:
			ind += 1
			continue
		if (S[ind + 1] - S[ind]) * (ind + 1) <= k:
			k -= (S[ind + 1] - S[ind]) * (ind + 1)
			ind += 1
		else:
			print(S[ind] + k // (ind + 1))
			break


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
low = a[n // 2]
high = 2 * 10 ** 9 + 5

def ok(x):
	r = 0
	for i in range(n // 2, n):
		if a[i] < x:
			r += x - a[i]
	return r <= k
while low + 1 < high:
	mid = (low + high) // 2
	if ok(mid):
		low = mid
	else:
		high = mid
print(low)


d = input().split(' ')
d = [int(i) for i in d]
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a)

def can(m):
	sum = 0
	for i in range(d[0] // 2, d[0]):
		if m > a[i]:
			sum += m - a[i]
	return d[1] >= sum
l = 0
r = int(1e+17)
while r - l > 1:
	m = (r + l) // 2
	if can(m):
		l = m
	else:
		r = m
print(l)


R = lambda : map(int, input().split())
(n, k) = R()
L = sorted(R())
if n == 1:
	print(L[0] + k)
	quit()
i = n // 2
m = L[i]
s = 0
T = [0]
i += 1
l = 0
while i < n:
	p = s
	t = L[i] - L[i - 1]
	s += t
	s += t * l
	T.append(s)
	i += 1
	l += 1
j = 0
while j < len(T):
	if k < T[j]:
		break
	j += 1
k -= T[j - 1]
m = L[n // 2 + j - 1]
if k > 0:
	m += k // j
print(m)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
md = n // 2
lo = l[md]
hi = int(10000000000.0)
ans = l[md]
while lo <= hi:
	mid = (lo + hi) // 2
	reqk = 0
	for i in range(n // 2, n):
		if l[i] < mid:
			reqk += mid - l[i]
	if reqk <= k:
		ans = mid
		lo = mid + 1
	else:
		hi = mid - 1
print(ans)


import bisect
(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
if n == 1:
	print(ai[0] + k)
else:
	ai.sort()
	k_li = []
	z = n // 2
	count = 1
	val = 0
	ans = 0
	for i in range(z, n - 1):
		val = val + (ai[i + 1] - ai[i]) * count
		k_li.append(val)
		count += 1
	index = bisect.bisect_right(k_li, k)
	if index > 0:
		k -= k_li[index - 1]
		ans += ai[z + index] + k // (index + 1)
		print(ans)
	if index == 0:
		print(ai[z] + k)


def isPossible(x, k):
	temp = a.copy()
	for i in range(int(n / 2), n):
		if x > temp[i]:
			diff = x - temp[i]
			k -= diff
			temp[i] = x
			if temp[i] < temp[i - 1] or k < 0:
				return False
		else:
			break
	return True
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
mid = int(n / 2)
l = a[mid]
h = a[mid] + k
res = l
while l <= h:
	mid = int(l + (h - l) / 2)
	if isPossible(mid, k):
		res = mid
		l = mid + 1
	else:
		h = mid - 1
print(res)


def main():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	i = n // 2
	count = k
	ans = a[n // 2]
	while i < n - 1 and count - (a[i + 1] - a[i]) * (i - n // 2 + 1) >= 0:
		count -= (a[i + 1] - a[i]) * (i - n // 2 + 1)
		ans = a[i + 1]
		i += 1
	print(ans + count // (i - n // 2 + 1))
main()


import math
[n, k] = list(map(int, input().rstrip().split()))
l = list(map(int, input().rstrip().split()))
v = sorted(l)
j = 1
somma = 0
while j + n // 2 < n and somma + j * (v[j + n // 2] - v[j + n // 2 - 1]) <= k:
	somma += (v[j + n // 2] - v[j + n // 2 - 1]) * j
	j += 1
ris = v[n // 2 + j - 1]
if somma <= k:
	ris += (k - somma) // j
print(ris)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
	print(arr[0] + k)
else:
	res = 0
	arr.sort()
	a = arr[n // 2:]
	diff = []
	for i in range(1, len(a)):
		diff.append(a[i] - a[i - 1])
	l = 0
	while k > 0 and l < len(diff):
		if k > diff[l] * (l + 1):
			k -= diff[l] * (l + 1)
			l += 1
		else:
			res = a[l] + k // (l + 1)
			k = 0
	if k > 0:
		res = a[~0] + k // len(a)
	print(res)


import re
from collections import deque
from functools import reduce
from heapq import *
from itertools import permutations
from math import pi
from operator import itemgetter
from operator import mul
from operator import xor
from os import linesep

def fmatr(matrix, lnsep: str=linesep, fieldsep: str=' ') -> str:
	return lnsep.join(map(lambda row: fieldsep.join(map(str, row)), matrix))

def fbool(boolval: int) -> str:
	return ['No', 'Yes'][boolval]

def solve() -> None:
	(n, k, *a) = map(int, open(0).read().split())
	a.sort()
	area = 0
	w = n // 2
	h = a[n // 2]
	for i in range(n // 2, n):
		(tw, th) = (i, a[i])
		addArea = (tw - n // 2) * (th - h)
		ta = area + addArea
		if ta > k:
			break
		(w, h, area) = (tw, th, ta)
	ans = h + (k - area) // (w - n // 2 + 1)
	print(ans)
solve()


class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, k) = Read.list_int()
	a = Read.list_int()
	a.sort()
	m_index = n // 2
	a = a[m_index:]
	current_m = a[0]
	index = 0
	while True:
		next_el = current_m
		while next_el <= current_m:
			index += 1
			if index == len(a):
				print(k // len(a) + current_m)
				return
			next_el = a[index]
		k_m = (next_el - current_m) * index
		if k_m <= k:
			k -= k_m
			current_m = next_el
		else:
			print(k // index + current_m)
			return
query_count = 1
for j in range(query_count):
	solve()


(n, k) = map(int, input().split())
A = sorted([int(x) for x in input().split()])
A += [2 * 10 ** 9 + 1]
mid = n // 2
i = mid
result = -1
while k > 0:
	while A[i] == A[i + 1]:
		i += 1
	d = A[i + 1] - A[i]
	if (i + 1 - mid) * d <= k:
		k -= (i + 1 - mid) * d
		i += 1
		result = A[i]
	else:
		result = A[i] + k // (i + 1 - mid)
		k = 0
print(result)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
if n == 1:
	print(k + a[0])
	raise SystemExit
d = [a[0]] + [a[i + 1] - a[i] for i in range(len(a) - 1)]
for i in range(n // 2 + 1, n):
	if k <= 0:
		break
	e = min(k // (i - n // 2), d[i])
	d[n // 2] += e
	d[i] -= e
	k -= e * (i - n // 2)
d[n // 2] += k // (n - n // 2)
r = 0
for i in range(n // 2 + 1):
	r += d[i]
print(r)


(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split())))[n // 2:]
n = len(a)

def f(x):
	return sum((max(0, x - a[i]) for i in range(n)))
(l, r) = (a[0], 2 * 10 ** 9 + 2)
while r - l > 1:
	m = (l + r) // 2
	if f(m) <= k:
		l = m
	else:
		r = m
if f(r) <= k:
	print(r)
else:
	print(l)


def check(mid, k, n):
	cnt = 0
	for i in range(n // 2, n):
		cnt += mid - ar[i]
		if cnt > k:
			return False
	if cnt <= k:
		return True
	else:
		return False

def solve(n, k, ar):
	ar.sort()
	l = 1
	h = 2000000000
	while l != h:
		mid = (l + h + 1) // 2
		if check(mid, k, n) is False:
			h = mid - 1
		else:
			l = mid
	print(l)
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
solve(n, k, ar)


(n, k) = [int(i) for i in input().split()]
ns = [int(i) for i in input().split()]
ns2 = ns
ns2.sort()
meio = n // 2
ns2 = ns2[meio:]
arrdif = []
arrdif.append(ns2[0])
for (i, item) in enumerate(ns2[1:]):
	arrdif.append(item - ns[i + meio])
for (i, dif) in enumerate(arrdif[1:]):
	if dif > 0:
		aux = dif * (i + 1)
		if k >= aux:
			k -= aux
			arrdif[0] += aux // (i + 1)
		else:
			arrdif[0] += k // (i + 1)
			k = 0
	if k == 0:
		break
if k > 0:
	arrdif[0] += k // len(arrdif)
print(arrdif[0])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
index = n >> 1
cur = a[index]
i = index + 1
index = 1
while k > 0 and i < len(a):
	p = (a[i] - a[i - 1]) * index
	if k < index:
		break
	elif p <= k:
		cur = a[i]
		k = k - p
		index += 1
		i += 1
	else:
		cur = cur + k // index
		break
if i == len(a):
	cur = cur + k // index
print(cur)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
MIN = 1
MAX = max(A) + k
while MIN != MAX:
	AVE = (MIN + MAX + 1) // 2
	score = 0
	for i in range(n // 2 + 1):
		if AVE > A[i]:
			score += AVE - A[i]
	if score > k:
		MAX = AVE - 1
	else:
		MIN = AVE
print(MIN)


from sys import stdin

def check(num, arr, k):
	i = len(arr) - 1
	while i >= len(arr) // 2:
		if arr[i] >= num:
			pass
		else:
			k -= abs(num - arr[i])
		i -= 1
	if k >= 0:
		return True
	else:
		return False
(n, k) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
arr.sort()
middle = arr[n // 2]
start = middle
end = middle + k
while True:
	if start >= end:
		if check(start + 1, arr, k):
			start += 1
		break
	mid = (start + end) // 2
	if check(mid, arr, k):
		start = mid + 1
	else:
		end = mid - 1
if check(start, arr, k):
	print(start)
else:
	print(start - 1)


(n, k) = map(int, input().strip().split())
numbers = list(map(int, input().strip().split()))
numbers.sort()
p = numbers[n // 2]
s = 0
t = 0
for i in range(n // 2, n - 1):
	p1 = (k - s) // (i - n // 2 + 1)
	s = s + min(p1, numbers[i + 1] - p) * (i - n // 2 + 1)
	t = t + min(p1, numbers[i + 1] - p)
	if p1 < numbers[i + 1] - p:
		break
	p = numbers[i + 1]
else:
	t = t + (k - s) // (n // 2 + 1)
print(t + numbers[n // 2])


(n, k) = (*map(int, input().split()),)
a = [int(x) for x in input().split()]
a.sort()
md = n // 2
wnl = 1
ub = a[md + wnl] if md + wnl < n else 10 ** 10
v = a[md]
while k:
	while md + wnl < n:
		if a[md + wnl] != v:
			break
		wnl += 1
	ub = a[md + wnl] if md + wnl < n else 10 ** 10
	gp = ub - v
	tms = min(k // wnl, gp)
	if not tms:
		break
	k -= wnl * tms
	v += tms
print(v)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
	print(a[0] + k)
	exit(0)
a = sorted(a)
a = a[int(n / 2):] + [10 ** 10]
n = int(n / 2) + 2
(m, next) = (a[0], a[1])
(ans, nans) = (m, 1)
while k > 0:
	dx = k / nans
	dy = next - ans
	if dx <= dy:
		ans = ans + dx
		break
	k -= dy * nans
	ans = next
	nans += 1
	next = a[nans]
print(int(ans))


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
t = s[-(n // 2)] - s[n // 2]
if k <= t or n == 1:
	print(s[n // 2] + k)
else:
	s = s[n // 2:]
	ans = s[0]
	t = s[0]
	s = list(filter(lambda x: x <= k, map(lambda x: x - t, s)))
	t = s[0]
	i = 1
	while i < len(s) and k >= 0:
		d = i
		if d * (s[i] - s[i - 1]) <= k:
			k -= d * (s[i] - s[i - 1])
			ans += s[i] - s[i - 1]
		else:
			ans += k // d
			break
		i += 1
	if i == len(s):
		ans += k // (d + 1)
	print(ans)


(n, k) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
a.sort()
median = a[n // 2]
mid = n // 2
if n == 1:
	print(a[0] + k)
else:
	if k <= a[mid + 1] - a[mid]:
		median += k
	else:
		median = a[mid + 1]
		k -= a[mid + 1] - a[mid]
		req = 0
		f = 2
		for i in range(mid + 1, n - 1):
			req = (a[i + 1] - a[i]) * f
			if k >= req:
				median = a[i + 1]
			else:
				median += k // f
				k -= req
				break
			k -= req
			f += 1
		if k > 0:
			median += k // (mid + 1)
	print(median)


import os
import sys
from io import BytesIO, IOBase
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')
(n, k) = list(map(int, input().rstrip().split(' ')))
a = sorted(list(map(int, input().rstrip().split(' '))))
middle = n // 2
curIdx = middle + 1
answer = a[middle]
while curIdx < n and k > 0:
	curLen = curIdx - middle
	toUp = min(k // curLen, a[curIdx] - answer)
	answer += toUp
	k -= toUp * curLen
	curIdx += 1
if k > 0:
	answer += k // (curIdx - middle)
print(answer)


import sys
input = sys.stdin.readline
(N, K) = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
A.sort()
med = A[N // 2]
n = K
key = N // 2
num = 1
if N > 1:
	while key < N - 1 and n >= (A[key + 1] - A[key]) * num:
		med += A[key + 1] - A[key]
		n -= (A[key + 1] - A[key]) * num
		key += 1
		num += 1
	if key == N - 1:
		med += n // (N // 2 + 1)
	else:
		med += n // num
else:
	med += K
print(med)


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
lis.sort()
mid = len(lis) // 2
c = 0
i = 1
ans = lis[mid]
while i < n - mid:
	l = lis[mid + i] - ans
	if k - c >= l * i:
		c += l * i
		ans += l
	else:
		ans += (k - c) // i
		c = k
		break
	i += 1
if c < k:
	ans += (k - c) // (mid + 1)
print(ans)


(n, k) = map(int, input().split())
mass = [int(i) for i in input().split()]
mass.sort()
mass = mass[(n - 1) // 2:]
lent = (n - 1) // 2 + 1
i = 0
num = 1
myx = mass[0]
while k > 0:
	i += 1
	if i == lent:
		myx += k // num
		break
	maxx = mass[i]
	k -= num * (maxx - myx)
	if k <= 0:
		k += num * (maxx - myx)
		myx = myx + k // num
		break
	else:
		myx = maxx
		num += 1
print(myx)


def solve():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = sorted(a)
	median = int(n / 2)
	left = a[median]
	right = 2 * 1000 * 1000 * 1000
	while left < right:
		middle = int((left + right + 1) / 2)
		need = 0
		for i in range(median, n, 1):
			if a[i] < middle:
				need += middle - a[i]
			else:
				break
		if need > k:
			right = middle - 1
		else:
			left = middle
	print(left)
solve()


import sys
input = sys.stdin.readline

def judge(x):
	cnt = 0
	for i in range(n // 2, n):
		cnt += max(x - a[i], 0)
	return cnt <= k

def binary_search():
	(left, right) = (1, 10 ** 20)
	while left <= right:
		mid = (left + right) // 2
		if judge(mid):
			left = mid + 1
		else:
			right = mid - 1
	return right
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
print(binary_search())


(n, m) = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])[n // 2:]
l = 0
r = 10 ** 10
while r - l > 1:
	mid = (l + r) // 2
	arr = 0
	for item in a:
		arr += max(0, mid - item)
	if arr > m:
		r = mid
	else:
		l = mid
print(l)


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
l = l[n // 2:]
while k != 0:
	mini = l[0]
	compte = l.count(mini)
	if compte == len(l):
		reste = k // len(l)
		l[0] += reste
		k = 0
		break
	deux_mini = l[compte]
	diff = deux_mini - mini
	if k >= diff * compte:
		k -= diff * compte
		for i in range(compte):
			l[i] = deux_mini
	else:
		reste = k // compte
		l[0] += reste
		k = 0
		break
print(l[0])


from sys import stdin, stdout, exit
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
a.sort()
a = a[(n - 1) // 2:]
sums = [0]
total = 0
for i in range((n + 1) // 2):
	total += a[i]
	sums.append(total)

def doable(tgt):
	if a[0] >= tgt:
		return True
	ct = 0
	hi = (n + 1) // 2
	while ct + 1 < hi:
		mid = (ct + hi) // 2
		if a[mid] < tgt:
			ct = mid
		else:
			hi = mid
	return tgt * (ct + 1) - sums[ct + 1] <= k
lo = 1
hi = 10 ** 15
while lo + 1 < hi:
	mid = (lo + hi) // 2
	if doable(mid):
		lo = mid
	else:
		hi = mid
stdout.write(str(lo) + '\n')


import os
import sys
from io import BytesIO, IOBase
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')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	(n, k) = RL()
	arr = list(RL())
	arr.sort()
	m = n // 2
	tag = m
	while k > 0:
		while tag < n and arr[tag] == arr[m]:
			tag += 1
		if tag == n:
			arr[m] += k // (tag - m)
			break
		else:
			now = min(arr[tag], arr[m] + k // (tag - m))
			dif = now - arr[m]
			if dif == 0:
				break
			k -= dif * (tag - m)
			arr[m] = now
	print(arr[m])
main()


import sys
(n, k) = list(map(int, sys.stdin.readline().strip().split()))
a = list(map(int, sys.stdin.readline().strip().split()))
m = n // 2
a.sort()
d = 1
ans = a[m]
if ans != a[n - 1]:
	while ans == a[m + d]:
		d = d + 1
else:
	d = n // 2 + 1
while d <= k and k > 0:
	k = k - d
	ans = ans + 1
	if ans < a[n - 1]:
		while ans == a[m + d]:
			d = d + 1
	else:
		d = n // 2 + 1
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
lo = 0
hi = 2000000000

def check(b, m, x):
	size = len(b)
	b.sort()
	need = 0
	for i in range(size // 2, size):
		need += max(0, m - b[i])
	if k >= need:
		return 1
	return 0
while lo != hi:
	mid = (lo + hi + 1) // 2
	if check(a, mid, k):
		lo = mid
	else:
		hi = mid - 1
print(hi)


line1 = input().split()
(n, m) = (int(line1[0]), int(line1[1]))
lst = input().split()
lst = [int(x) for x in lst]
lst.sort()
median = n // 2
lst = lst[median:]
total = []
for i in range(len(lst)):
	if i == 0:
		total.append(lst[i])
	else:
		total.append(total[-1] + lst[i])

def eval(lst, total, index):
	target = lst[index]
	target_total = target * (index + 1)
	actual_total = total[index]
	return target_total - actual_total
start = 0
end = len(total) - 1
largest = 0
while start <= end:
	mid = (start + end) // 2
	amount_needed = eval(lst, total, mid)
	if amount_needed == m:
		largest = mid
		break
	elif amount_needed < m:
		largest = max(largest, mid)
		start = mid + 1
	else:
		end = mid - 1
leftover = m - eval(lst, total, largest)
print(lst[largest] + leftover // (largest + 1))


(valuenum, operationnum) = [int(x) for x in input().split(' ')]
values = [int(x) for x in input().split(' ')]
values.sort()
req = 0
lastmax = values[(valuenum - 1) // 2]
canfill = True
inclusions = 0
for i in range(1, (valuenum - 1) // 2 + 1):
	inclusions = i
	if values[(valuenum - 1) // 2 + i] > lastmax:
		if req + (values[(valuenum - 1) // 2 + i] - lastmax) * i <= operationnum:
			req += (values[(valuenum - 1) // 2 + i] - lastmax) * i
			lastmax = values[(valuenum - 1) // 2 + i]
		else:
			canfill = False
			break
if canfill:
	print(values[-1] + (operationnum - req) // ((valuenum - 1) // 2 + 1))
else:
	print(lastmax + (operationnum - req) // inclusions)


(x, y) = map(int, input().split())
s = sorted(list(map(int, input().split())))

def ck(x, y, s):
	res = 0
	ln = len(s)
	for n in range(ln // 2, ln):
		res += max(0, x - s[n])
	return res <= y
res = 0
hi = 10 ** 10
lo = 0
while hi >= lo:
	mid = (hi + lo) // 2
	if ck(mid, y, s):
		res = mid
		lo = mid + 1
	else:
		hi = mid - 1
print(res)


def cond(a, n, k, v):
	s = 0
	for i in range(n // 2, n):
		s += max(0, v - a[i])
	return s <= k

def bin_search(a, n, k):
	(left, right) = (-1, 10 ** 18)
	while right - left > 1:
		mid = (right + left) // 2
		if cond(a, n, k, mid):
			left = mid
		else:
			right = mid
	if left < 0:
		return right
	return left

def main():
	(n, k) = map(int, input().split())
	numbers = list(map(int, input().split()))
	numbers.sort()
	print(bin_search(numbers, n, k))
main()


def possible(l, mid, k, n):
	add = 0
	for i in range(n // 2, n):
		if mid - l[i] > 0:
			add += mid - l[i]
			if add > k:
				return 1
	if add <= k:
		return 0
	else:
		return 1
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
low = 1
high = m + max(l)
l.sort()
while low <= high:
	mid = (low + high) // 2
	if possible(l, mid, m, n) == 0:
		low = mid + 1
	else:
		high = mid - 1
print(low - 1)


def read_ints():
	return map(int, input().split(' '))
(n, k) = read_ints()
a = list(read_ints())
a.sort()
idx = n // 2
length = 1
ans = a[idx]
while idx < n - 1 and k >= length:
	nxt = a[idx + 1]
	delta = min(nxt - a[idx], k // length)
	k -= delta * length
	ans = a[idx] + delta
	idx += 1
	length += 1
if idx == n - 1 and k >= length:
	ans = a[idx] + k // length
print(ans)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a += [10 ** 10]
m = (n - 1) // 2
med = 0
summ = 0
for i in range(m, n):
	summ += a[i]
	c = min(a[i + 1], math.floor((k + summ) / (i + 1 - m)))
	if c < a[i]:
		break
	if c > med:
		med = c
print(med)


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
med = l[n // 2]
for i in range(n // 2 + 1, n):
	diff = l[i] - l[i - 1]
	if diff > 0:
		if k >= diff * (i - n // 2):
			med = l[i]
			k -= diff * (i - n // 2)
		else:
			if k >= i - n // 2:
				med = med + k // (i - n // 2)
				k -= k // (i - n // 2) * (i - n // 2)
			break
num = n // 2 + 1
if k < num:
	print(med)
else:
	print(med + k // num)


mod = 1000000007
MOD = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
it = lambda : tuple(map(int, input().split()))
ls = lambda : list(input())
(n, k) = f()
diff = []
sm = 0
l = sorted(il())
if n == 1:
	print(l[0] + k)
	exit()
for i in range(n // 2 + 1, n):
	sm += (i - n // 2) * (l[i] - l[i - 1])
	diff.append([sm, l[i]])
mx = l[n // 2]
if k > diff[-1][0]:
	print(diff[-1][1] + (k - diff[-1][0]) // ((n + 1) // 2))
	exit()
diff = [[0, l[n // 2]]] + diff
for i in range(1, len(diff)):
	if k <= diff[i][0]:
		print(diff[i - 1][1] + (k - diff[i - 1][0]) // i)
		exit()
print(mx)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
m = n // 2
a.sort()
fst = 1
lst = int(2000000000.0)
while fst != lst:
	mid = (fst + lst + 1) // 2
	tmp = 0
	for i in range(m, n):
		if mid - a[i] > 0:
			tmp += mid - a[i]
		if tmp > k:
			lst = mid - 1
			break
	if tmp <= k:
		fst = mid
print(fst)


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


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
count = A[n // 2]
num = 1
for i in range(n // 2 + 1, n):
	if (A[i] - count) * num <= k:
		k -= (A[i] - count) * num
		count = A[i]
	else:
		break
	num += 1
print(count + k // num)


from bisect import *
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
length = len(l)
med = n // 2 + 1
median = l[n // 2]
while k > 0:
	index = bisect_right(l, median)
	if index < length:
		next_val = l[index]
		if k >= (next_val - median) * (index - n // 2):
			k = k - (next_val - median) * (index - n // 2)
			median = next_val
		else:
			median += k // (index - n // 2)
			break
	else:
		median += k // (index - n // 2)
		break
print(median)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
idex = n // 2
last = -1
avilable = -1
for i in range(idex, n - 1):
	need = a[i + 1] - a[i]
	if need:
		real = (i + 1 - idex) * need
		if k >= real:
			a[i] += need
			k -= real
		else:
			avilable = k // (i + 1 - idex)
			last = i
			break
if last == -1:
	avilable = k // (n - idex)
	print(a[n - 1] + avilable)
else:
	print(a[last] + avilable)


(n, k) = map(int, input().split(' '))
arr = [int(i) for i in input().split(' ')]
arr.sort()
(l, r) = (arr[n // 2], int(2000000000.0 + 5))
while l < r:
	mid = (l + r + 1) // 2
	reqd = 0
	for i in range(n // 2, n):
		reqd += max(mid - arr[i], 0)
	if reqd > k:
		r = mid - 1
	else:
		l = mid
print(l)


import sys

def binary_search(start, end, array, n, k):
	solution = 0
	while start <= end:
		med = (start + end) // 2
		count = 0
		for idx in range((n + 1) // 2 - 1, n):
			count += max(med - array[idx], 0)
		if count <= k:
			start = med + 1
			solution = max(solution, med)
		else:
			end = med - 1
	return solution

def main():
	sys.setrecursionlimit(10 ** 6)
	(N, K) = list(map(int, input().split()))
	ARRAY = list(map(int, input().split()))
	ARRAY = sorted(ARRAY)
	sol = binary_search(min(ARRAY), max(ARRAY) + K, ARRAY, N, K)
	print(sol)
main()


y = lambda : map(int, input().split())
(n, k) = y()
a = sorted(y()) + [(1 << 31) - 1]
d = 1
i = n // 2
v = a[i]
while k >= d:
	while d < n - i and v == a[i + d]:
		d += 1
	r = min(k // d, a[i + d] - v)
	v += r
	k -= d * r
print(v)


def f(v, mid, N, K):
	last_max = v[N // 2] + mid
	cur = K - mid
	for i in range(N // 2 + 1, N):
		needed = last_max - v[i]
		if needed > 0:
			cur -= needed
			if cur < 0:
				return False
		else:
			break
	return True

def main():
	(N, K) = map(int, input().split())
	v = list(map(int, input().split()))
	v.sort()
	(s, e, mid, sol) = (0, K, 0, 0)
	while s <= e:
		mid = s + (e - s) // 2
		if f(v, mid, N, K):
			s = mid + 1
			sol = mid
		else:
			e = mid - 1
	print(v[N // 2] + sol)
main()


def check(n1):
	c = 0
	for i in range(n // 2, n):
		c += n1 - a[i]
		if c > k:
			return False
	if c <= k:
		return True
	return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = a[n // 2]
e = a[n // 2] + k
while s <= e:
	mid = (s + e) // 2
	if check(mid):
		s = mid + 1
	else:
		e = mid - 1
print(e)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
piv = N // 2
A.sort()
ans = A[piv]
k = 0
for i in range(piv + 1, N):
	if ans < A[i]:
		a = (A[i] - ans) * (i - piv)
		if k + a > K:
			ans += (K - k) // (i - piv)
			k += a
			break
		else:
			ans = A[i]
			k += a
if k < K:
	ans += (K - k) // (N - piv)
print(ans)


from math import ceil

def func(a, k, x, n):
	p = 0
	i = 0
	while i < ceil(n / 2):
		if a[i] < x:
			p += x - a[i]
		i += 1
	if p > k:
		return False
	else:
		return True
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
if n == 1:
	print(a[0] + k)
else:
	a.sort(reverse=True)
	low = a[ceil(n / 2)]
	high = 10 ** 10
	an = low
	while high >= low:
		mid = (low + high) // 2
		if func(a, k, mid, n):
			low = mid + 1
			an = mid
		else:
			high = mid - 1
	print(an)


(n, k) = map(int, input().split())
u = list(map(int, input().split()))
u.sort()
if n == 1:
	print(u[0] + k)
	exit()
ans = u[n // 2]
num = 1
for i in range(n // 2 + 1, n):
	if (u[i] - u[i - 1]) * (i - n // 2) <= k:
		k -= (u[i] - u[i - 1]) * (i - n // 2)
		ans = u[i]
		num += 1
	else:
		break
ans += k // num
print(ans)


(n, k) = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])
c = 1
ans = a[n // 2]
for i in range(n // 2, n - 1):
	if a[i + 1] != a[i]:
		r = a[i + 1] - a[i]
		if k - c * r < 0:
			ans += k // c
			break
		k -= c * r
		ans += r
	c += 1
else:
	ans += k // (n // 2 + 1)
print(ans)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
mid = int((n - 1) / 2)
jsj = 1
for i in range(mid + 1, n):
	if a[i] == a[i - 1]:
		jsj += 1
	else:
		if k <= jsj * (a[i] - a[i - 1]):
			ans = a[i - 1] + int(k / jsj)
			k -= jsj * (a[i] - a[i - 1])
			break
		k -= jsj * (a[i] - a[i - 1])
		jsj += 1
if k > 0:
	ans = a[n - 1] + int(k / jsj)
print(ans)


from sys import stdin, stdout
(N, K) = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
arr.sort()
half = N // 2
s = sum(arr[half:])
bound = s + K
res = 0
for i in range(N - 1, N // 2 - 1, -1):
	if bound // (i - half + 1) > arr[i]:
		res = max(res, bound // (i - half + 1))
		if i != N - 1 and res > arr[i + 1]:
			res = arr[i + 1]
		break
	else:
		bound -= arr[i]
print(res)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
same = 1
mid = n // 2
while k > 0:
	if same <= mid:
		diff = l[mid + same] - l[mid]
		temp = k
		k -= diff * same
		if k >= 0:
			l[mid] = l[mid + same]
		else:
			l[mid] = l[mid] + temp // same
	else:
		l[mid] = l[mid] + k // same
		k = 0
	same += 1
print(l[mid])


def good(m, a, k):
	x = 0
	for i in range(n // 2, n):
		if m - a[i] > 0:
			x += m - a[i]
	if x <= k:
		return 1
	else:
		return 0
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 1
r = 10 ** 11
while r > l + 1:
	m = (l + r) // 2
	if good(m, a, k) == 1:
		l = m
	else:
		r = m
print(l)


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	mid = n // 2
	i = mid + 1
	final_val = a[mid]
	while i < n and k > 0:
		if a[mid] != a[i]:
			if k >= (a[i] - a[mid]) * (i - mid):
				k -= (a[i] - a[mid]) * (i - mid)
				final_val = a[i]
				a[mid] = a[i]
			else:
				final_val += k // (i - mid)
				k = 0
				break
		i += 1
	if k > 0 and i == n:
		final_val += k // (i - mid)
	print(final_val)
main()


def num_operations(daList, targetNum, numOpp):
	num = 0
	for i in range(len(daList) // 2, len(daList)):
		num += (targetNum - daList[i]) * (daList[i] < targetNum)
	return num <= numOpp

def binary_search(low, high, givenList, numOpp):
	res = low - 1
	while low <= high:
		mid = (low + high) // 2
		if num_operations(givenList, mid, numOpp):
			res = mid
			low = mid + 1
		else:
			high = mid - 1
	return res
(numEle, numOpp) = map(int, input().split())
numbers = sorted(map(int, input().split()))
print(binary_search(numbers[numEle // 2], numbers[numEle // 2] + numOpp, numbers, numOpp))


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
import io
import os
input = sys.stdin.readline
import random
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def pref(a, n, f):
	pre = [0] * n
	if f == 0:
		pre[0] = a[0]
		for i in range(1, n):
			pre[i] = a[i] + pre[i - 1]
	else:
		pre[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			pre[i] = pre[i + 1] + a[i]
	return pre
for _ in range(1):
	(n, k) = cin()
	l = ain()
	l.sort()
	d = dd(int)
	ele = dd(int)
	pre = pref(l, n, 0)
	for i in range(n // 2 + 1, n):
		d[l[i]] = l[i] * (i - n // 2 + 1) - (pre[i] - pre[n // 2 - 1])
		ele[l[i]] = i
	ans = [0] + list(d.values())
	num = [l[n // 2]] + list(d.keys())
	pos = bi.bisect(ans, k)
	dif = k - ans[pos - 1]
	den = max(ele[num[pos - 1]] - n // 2 + 1, 1)
	add = 0
	if den != 0:
		add = dif // den
	print(num[pos - 1] + add)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a = a[n // 2:]
n = n // 2 + 1
n_inc = 1
while m > 0:
	while n_inc < n and a[n_inc - 1] == a[n_inc]:
		n_inc += 1
	if n_inc == n:
		to_inc = m // n_inc
	else:
		to_inc = min(m // n_inc, a[n_inc] - a[n_inc - 1])
	total_inc = n_inc * to_inc
	m -= total_inc
	a[n_inc - 1] += to_inc
	if n_inc == n or to_inc == 0:
		break
print(a[n_inc - 1])


import sys
import bisect
input = lambda : sys.stdin.readline().rstrip()
(n, k) = list(map(int, input().split()))
arr = sorted(map(int, input().split()))
mid = arr[n // 2]
s = mid
e = int(2000000000.0)
while s <= e:
	m = (s + e) // 2
	z = 0
	for i in range(n // 2, bisect.bisect_left(arr, m)):
		if m > arr[i]:
			z += m - arr[i]
	if z > k:
		e = m - 1
	else:
		s = m + 1
print(e)


import math, bisect
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
(n, k) = M()
a = LI()
a.sort()
medianIndex = n // 2
a = a[medianIndex:]
left = 1
right = 10 ** 10
while left < right:
	mid = (left + right + 1) // 2
	count = 0
	for i in range(len(a)):
		count += max(0, mid - a[i])
	if count > k:
		right = mid - 1
	else:
		left = mid
print(left)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ind = n // 2 + 1
mid = n // 2
median = a[mid]
while ind < n and a[ind] == median:
	ind += 1
while k >= ind - mid:
	median += 1
	k -= ind - mid
	while ind < n and a[ind] == median:
		ind += 1
print(median)


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

def check(x):
	moves = 0
	for i in range(n // 2, n):
		if x - arr[i] > 0:
			moves += x - arr[i]
		if moves > k:
			return False
	if moves <= k:
		return True
	else:
		return False
small = 1
big = 2000000000
while small != big:
	mid = (small + big + 1) // 2
	if check(mid):
		small = mid
	else:
		big = mid - 1
print(small)


def bs(l, h):
	while l < h:
		m = (l + h + 1) // 2
		if gf(m):
			l = m
		else:
			h = m - 1
	return l

def gf(x):
	s = 0
	for i in a[m:]:
		s += max(0, x - i)
	return s <= k
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
m = n // 2
print(bs(a[m], a[m] + k))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a + [a[n - 1]]
c = 0
m = (n - 1) // 2
i = m
if i + 1 < n:
	add = (a[i + 1] - a[i]) * (i - m + 1)
while i + 1 < n and c + add <= k:
	c += add
	i += 1
	add = (a[i + 1] - a[i]) * (i - m + 1)
a[i] += (k - c) // (i - m + 1)
print(a[i])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
	print(arr[0] + k)
	exit(0)
arr.sort()
mid = n // 2
piv = mid + 1
maxm = arr[mid]
delta = arr[mid + 1] - arr[mid]
while k >= delta:
	k -= delta
	maxm = arr[piv]
	piv += 1
	if piv >= n:
		break
	delta = (piv - mid) * (arr[piv] - maxm)
if piv != mid:
	maxm += k // (piv - mid)
print(maxm)


(n, k) = map(int, input().split())
num = list(sorted(map(int, input().split())))
x1 = 1
x2 = 2000000000.0 + 1
while x1 <= x2:
	m = int((x1 + x2) / 2)
	s = 0
	for i in range(int(n / 2), n):
		s += max(0, m - num[i])
	if s <= k:
		ans = m
		x1 = m + 1
	else:
		x2 = m - 1
print(ans)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def check(x):
	c = 0
	for i in range(n // 2, n):
		if x - l[i] >= 0:
			c += x - l[i]
		if c > k:
			return False
	return c <= k
(n, k) = mp()
l = li()
l.sort()
(low, high) = (1, pow(10, 18))
ans = 0
while low <= high:
	mid = (low + high) // 2
	if check(mid):
		ans = mid
		low = mid + 1
	else:
		high = mid - 1
pr(ans)


def median(l, n, k):
	l = l[n // 2:]
	n = n // 2 + 1
	diffs = []
	for i in range(n - 1):
		diffs.append((l[i + 1] - l[i]) * (i + 1))
	diff = sum(diffs)
	if diff <= k:
		k -= diff
		last = l[-1] + k // n
		k %= n
		return last
	else:
		t = 0
		val = l[0]
		while t < n - 1:
			if diffs[t] <= k:
				val += diffs[t] // (t + 1)
				k -= diffs[t]
				t += 1
			else:
				val += k // (t + 1)
				break
			if k == 0:
				break
		return val
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(median(l, n, k))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
	print(a[0] + k)
else:
	a.sort()
	n = (n - 1) // 2
	a = a[n:]
	med = a[0]
	for i in range(0, n):
		add = min((a[i + 1] - a[i]) * (i + 1), k)
		k -= add
		med += add // (i + 1)
	med += k // (n + 1)
	print(med)


def check(x, A):
	mov = 0
	n = len(A)
	for i in range(n // 2, n):
		if x - A[i] > 0:
			mov += x - A[i]
		if mov > k:
			return False
	return True
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
l = 1
h = int(2000000000.0)
while l < h:
	mid = (l + h + 1) // 2
	if check(mid, A):
		l = mid
	else:
		h = mid - 1
print(l)


import sys
import math
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def check(val):
	global a
	if val < a[n // 2]:
		return 1
	else:
		res = 0
		for x in range(n // 2, n):
			res += max(0, val - a[x])
		if res <= m:
			return 1
	return 0
(l, r) = (a[0], 2000000009)
while r - l > 1:
	mid = (r + l) // 2
	if check(mid):
		l = mid
	else:
		r = mid
print(l)


[n, k] = list(map(int, input().split()))
s = list(map(int, input().split()))
s = sorted(s)
sum = 0
pos = n // 2
for i in range(n // 2, n - 1):
	sum = sum + s[n - 1] - s[i]
if k >= sum:
	res = s[n - 1] + (k - sum) // (n // 2 + 1)
else:
	for i in range(n - 2, n // 2 - 1, -1):
		sum = sum - pos * (s[i + 1] - s[i])
		if k >= sum:
			res = s[i] + (k - sum) // pos
		else:
			pos = pos - 1
			continue
print(res)


import atexit
import io
import sys
R = lambda : map(int, input().split())
(n, k) = R()
lst1 = list(R())
id = n // 2
lst1.sort()
for i in range(id, n - 1):
	if (lst1[i + 1] - lst1[i]) * (i + 1 - id) > k:
		print(lst1[i] + k // (i + 1 - id))
		exit()
	else:
		k -= (lst1[i + 1] - lst1[i]) * (i + 1 - id)
print(lst1[-1] + k // (n - id))


(n, k) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
a.sort()
m = int(n // 2)
flag = 0
v = a[m]
r = 0
for i in range(m + 1, n):
	p = r + (a[i] - a[i - 1]) * (i - m)
	if p < k:
		r = p
	else:
		v = a[i - 1] + int((k - r) // (i - m))
		flag = 1
		break
if flag == 0:
	v = a[n - 1] + int((k - r) // (n - m))
print(v)


from sys import stdin, stdout
import heapq

def maximum(arr, k):
	if len(arr) == 1:
		return arr[0] + k
	(i, count, rem) = (0, 1, arr[0])
	n = len(arr) + 1
	arr = arr + [10 ** 10]
	while k > 0 and i < n - 1:
		if arr[i] == arr[i + 1]:
			count += 1
		else:
			if (arr[i + 1] - rem) * count <= k:
				k -= (arr[i + 1] - rem) * count
				rem = arr[i + 1]
			else:
				rem += k // count
				k = 0
			count += 1
		i += 1
	return rem
(n, k) = map(int, stdin.readline().split())
l = list(map(int, stdin.readline().split()))
l.sort()
print(maximum(l[n // 2:], k))


attributes = [int(x) for x in input().split()]
ints = [int(x) for x in input().split()]
ints.sort()
length = len(ints)
n = len(ints) // 2 - 1
r = n
cont = True
while cont == True:
	r += 1
	t = ints[r]
	z = r + 1
	while z < length and ints[z] == ints[r]:
		z += 1
	if z != length:
		if (ints[z] - ints[r]) * (z - n - 1) <= attributes[1]:
			attributes[1] -= (ints[z] - ints[r]) * (z - n - 1)
			r = z - 1
		else:
			print(ints[r] + attributes[1] // (z - n - 1))
			cont = False
	else:
		print(ints[z - 1] + attributes[1] // (z - n - 1))
		cont = False


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
index = n // 2
a.sort()

def f(x):
	if a[index] >= x:
		return True
	tmp = k
	for val in a[index:]:
		if val >= x:
			return True
		tmp -= x - val
		if tmp < 0:
			return False
	return True
l = a[index]
r = l + k
ans = l
while l <= r:
	mid = (l + r) // 2
	if f(mid):
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()

def ok(center):
	global a, k, n
	kneed = 0
	for I in a[0:n // 2 + 1]:
		kneed += max(0, center - I)
	if kneed <= k:
		return True
	else:
		return False
L = 0
R = a[0] + k + 1
while R - L > 1:
	M = (L + R) // 2
	if ok(M):
		L = M
	else:
		R = M
print(L)


(size, k) = map(int, input().split())
array = sorted(list(map(int, input().split())))
median_pos = size // 2
increase_pos = list()
dif = list()
for x in range(median_pos + 1, size):
	cur = array[x]
	prev = array[x - 1]
	if cur != prev:
		increase_pos.append(x)
		dif.append(cur - prev)
increased = 0
stop = size
for x in range(len(increase_pos)):
	dif_range = increase_pos[x] - median_pos
	k_waste = dif_range * dif[x]
	if k_waste > k:
		stop = increase_pos[x]
		break
	increased += dif[x]
	k -= k_waste
	stop = increase_pos[x] + 1
num = stop - size // 2
times = k // num
result = increased + array[median_pos] + times
print(result)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
nn = (n + 1) // 2
A = [int(i) for i in input().split()]
A.sort(reverse=True)
A = A[:nn][::-1]
B = [0] * nn
for i in range(1, nn):
	B[i] = B[i - 1] + i * (A[i] - A[i - 1])
if k >= B[-1]:
	print((sum(A) + k) // nn)
else:
	import bisect
	b = bisect.bisect_left(B, k)
	print((sum(A[:b]) + k) // b)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
l = lst[n // 2]
r = 2000000000
while l <= r:
	mid = (l + r) // 2
	s = 0
	for i in range(n // 2, n):
		if lst[i] < mid:
			s += mid - lst[i]
	if s <= k:
		l = mid + 1
	else:
		r = mid - 1
print(r)


def check(x, a):
	moves = 0
	for i in range(n // 2, n):
		if x - a[i] > 0:
			moves += x - a[i]
		if moves > k:
			return False
	if moves <= k:
		return True
	else:
		return False
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
j = n // 2
r = n // 2 + 1
s = 1
b = 20000000000
while s != b:
	mid = (s + b) // 2 + 1
	if check(mid, a):
		s = mid
	else:
		b = mid - 1
print(s)


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
m = c[a // 2]
n = c[a // 2] + b

def check(mid):
	s = 0
	for i in range(a // 2, a):
		if mid > c[i]:
			s += mid - c[i]
		else:
			break
	return s
while m <= n:
	mid = (m + n) // 2
	if check(mid) <= b:
		m = mid + 1
	else:
		n = mid - 1
print(m - 1)


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

def find(m, k, a):
	for i in range(n):
		if k == 0:
			break
		if a[i] < m:
			temp = min(k, m - a[i])
			a[i] += temp
			k -= temp
		else:
			break
	if a[0] == m:
		for i in range(1, n):
			if not a[i] >= a[i - 1]:
				return False
		return True
	return False
a = sorted([int(x) for x in input().split()])[int(n / 2):]
n = len(a)
l = a[0]
h = a[n - 1] + k // n
ans = 0
while l <= h:
	m = (l + h) // 2
	if find(m, k, a.copy()):
		ans = max(ans, m)
		l = m + 1
	else:
		h = m - 1
print(ans)


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

def f(m, k, n, a):
	j = n // 2
	g = a[j]
	if m - g > 0:
		k -= m - g
	for i in range(j + 1, n):
		if a[i] <= m:
			k -= m - a[i]
	return k >= 0
l = a[0]
r = a[-1] + k + 1
while r - l > 1:
	m = (l + r) // 2
	if f(m, k, n, a):
		l = m
	else:
		r = m
print(l)


def mp():
	return map(int, input().split())
(n, k) = mp()
a = list(mp())
a.sort()
l = 1
r = 10 ** 20
while l + 1 < r:
	m = (l + r) // 2
	s = 0
	for i in range(n // 2, n):
		s += max(0, m - a[i])
	if k < s:
		r = m
	else:
		l = m
print(l)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mid = n // 2
for i in range(mid, n - 1):
	if k - (a[i + 1] - a[i]) * (i - mid + 1) >= 0:
		k -= (a[i + 1] - a[i]) * (i - mid + 1)
	else:
		exit(print(k // (i - mid + 1) + a[i]))
print(k // (n - mid) + a[-1])


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
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')

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()

	def check(m, b):
		cost = 0
		for x in b:
			if m <= x:
				break
			cost += m - x
		return cost <= k
	(l, r) = (a[n // 2], 2 * 10 ** 9)
	b = a[n // 2:]
	while l < r:
		mid = (l + r + 1) // 2
		if check(mid, b):
			l = mid
		else:
			r = mid - 1
	print(l)
main()


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
from collections import defaultdict
b = defaultdict(int)
c = set()
for i in a:
	b[i] += 1
	c.add(i)
a.sort()
(l, p, s) = (a[n // 2], a[n - 1], 0)
b[l] = 0
for i in range(n // 2, n):
	if a[i] == l:
		b[l] += 1
	else:
		break
b = sorted(zip(b.keys(), b.values()))
c = list(a)
c.sort()
w = len(c)
for i in range(w):
	if c[i] > l:
		r = i
		break
for i in b:
	if i[0] >= l:
		if k >= 0:
			if l == p:
				l += k // (i[1] + s)
			elif k >= (s + i[1]) * (c[r] - l):
				k = k - (s + i[1]) * (c[r] - l)
				s += i[1]
				l = c[r]
				r = r + 1
			else:
				l += k // (s + i[1])
				break
		else:
			break
print(l)


import sys
(n, k) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
a = sorted(a)

def check(x):
	moves = 0
	for i in range(n // 2, n):
		if x - a[i] > 0:
			moves = moves + x - a[i]
		if moves > k:
			return False
	if moves <= k:
		return True
	else:
		return False
small = 1
big = 2000000000
while small != big:
	mid = (small + big + 1) // 2
	if check(mid) == True:
		small = mid
	else:
		big = mid - 1
print(small)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(n, k) = sep()
	a = sorted(lis())
	mx = a[n - 1]
	a = a[n // 2:]
	h = []
	for i in range(len(a)):
		heappush(h, a[i])
	cnt = 1
	while len(h) != 1:
		f = heappop(h)
		s = heappop(h)
		if (s - f) * cnt <= k:
			k -= (s - f) * cnt
			cnt += 1
			heappush(h, s)
		else:
			print(f + k // cnt)
			return
	print(heappop(h) + k // cnt)
testcase(1)


from math import *
from sys import stdin
input = stdin.readline
INP = lambda : map(int, input().split())
(n, k) = INP()
a = sorted(INP())[n // 2:]
i = 0
for (x, y) in zip(a, a[1:] + [1 << 31]):
	i += 1
	d = min(y - x, k // i)
	a[0] += d
	k -= d * i
print(a[0])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
mid = n // 2
itr = 1
tot = 0
for i in range(mid + 1, n):
	if tot + (arr[i] - arr[i - 1]) * itr > k:
		break
	else:
		tot += (arr[i] - arr[i - 1]) * itr
		itr += 1
final = arr[mid + itr - 1] + (k - tot) // itr
print(final)


(n, k) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
a.sort()
b = a[n // 2:]

def p(m):
	ans = 0
	for s in b:
		if m <= s:
			break
		else:
			ans += m - s
	return ans <= k
low = b[0]
high = b[0] + k
while low < high:
	mid = low + (high - low + 1) // 2
	if p(mid):
		low = mid
	else:
		high = mid - 1
print(low)


from itertools import accumulate
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if len(a) == 1:
	print(a[0] + k)
else:
	a.sort()
	a = a[len(a) // 2:]
	b = list(accumulate(a))
	mx = 0
	if a[0] + k <= a[1]:
		mx = a[0] + k
	for i in range(1, len(a) - 1):
		lmax = a[i + 1]
		if (b[i] + k) // (i + 1) + 1 < a[i]:
			break
		elif lmax * (i + 1) - b[i] - k > i + 1:
			mx = max(mx, (b[i] + k) // (i + 1))
			break
		elif b[i] + k < lmax * (i + 1):
			mx = max(mx, (b[i] + k) // (i + 1))
		else:
			mx = max(mx, lmax)
	else:
		if b[-1] + k >= a[-1] * len(a):
			mx = max(mx, (b[-1] + k) // len(a))
	print(mx)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
c = 1
i = n // 2
s = a[i]
while i < n - 1 and k > 0:
	t = min(a[i + 1] - s, k // c)
	s += t
	k -= t * c
	c += 1
	i += 1
if k > 0:
	s += k // c
print(s)


(n, k) = map(int, input().split())
assert n % 2 == 1
arr = sorted(map(int, input().split()))
arr = arr[n // 2:]
med = arr[0]
for i in range(1, len(arr)):
	if k == 0:
		break
	if arr[i] == med:
		continue
	else:
		diff = arr[i] - med
		kdiff = min(diff * i, k)
		med += kdiff // i
		k -= kdiff
print(med + k // len(arr))


def f(tar, l, k):
	req = 0
	for i in range(len(l)):
		req += max(0, tar - l[i])
	if req <= k:
		return True
	else:
		return False
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l = l[n // 2:]
(low, high, ans) = (l[0], 10 ** 18, 0)
while low <= high:
	mid = low + (high - low) // 2
	x = f(mid, l, k)
	if x:
		ans = max(ans, mid)
		low = mid + 1
	else:
		high = mid - 1
print(ans)


import sys
import math
import bisect

def query(A, mval):
	n = len(A)
	m = (n - 1) // 2
	ans = mval - A[m]
	for i in range(m + 1, n):
		if A[i] < mval:
			ans += mval - A[i]
	return ans

def solve(A, k):
	n = len(A)
	m = (n - 1) // 2
	A.sort()
	left = A[m]
	right = A[m]
	while query(A, right) <= k:
		right <<= 1
	while right - left > 1:
		mid = (left + right) // 2
		if query(A, mid) <= k:
			left = mid
		else:
			right = mid
	return left

def main():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	ans = solve(A, m)
	print(ans)
main()


from bisect import bisect
(n, k) = [int(p) for p in input().split()]
arr = sorted([int(p) for p in input().split()])
diff = []
for i in range(n // 2, n - 1):
	diff.append(arr[i + 1] - arr[i])
for i in range(1, len(diff)):
	diff[i] += i * diff[i] + diff[i - 1]
i = bisect(diff, k)
if len(diff) == 0:
	print(arr[0] + k)
elif i < len(diff):
	if i != 0:
		k -= diff[i - 1]
	print(arr[n // 2 + i] + k // (i + 1))
else:
	k -= diff[-1]
	arr[-1] += k // (n // 2 + 1)
	print(arr[-1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
j = int(n / 2)
x = 1
ans = a[j]
while k > 0 and j < n - 1:
	y = a[j + 1] - a[j]
	if x * y <= k:
		k -= x * y
		x += 1
		ans = a[j + 1]
		j += 1
	else:
		ans += int(k / x)
		k = 0
		break
if k:
	ans += int(k / (int(n / 2) + 1))
print(ans)


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())
(n, k) = mi()
m = n // 2
a = li()
a.sort()
p = a[m]
b = []
x = 1
for j in range(m + 1, n):
	y = a[j] - p
	p += min(y, k // x)
	k -= y * x
	if k >= 0:
		x += 1
	else:
		break
if k > 0:
	p += k // (m + 1)
print(p)


(n, k) = [int(i) for i in input().split(' ')]
a = sorted([int(i) for i in input().split(' ')])
ans = a[n // 2]
tot = 0
for i in range(n // 2 + 1, n, 1):
	last = tot
	tot += (i - n // 2) * (a[i] - a[i - 1])
	if tot >= k:
		ans = ans + (k - last) // (i - n // 2)
		break
	ans = a[i]
if tot < k:
	ans = ans + (k - tot) // (n - n // 2)
print(ans)


def valid(a, mid, n, k):
	tot = 0
	x = int((n - 1) / 2)
	for i in range(x, n):
		tot += max(0, mid - a[i])
	if tot <= k:
		return True
	return False
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
s = 0
e = 10000000000
while s <= e:
	mid = int((s + e) / 2)
	fb = valid(a, mid, n, k)
	sb = valid(a, mid + 1, n, k)
	if fb == True and sb == False:
		print(mid)
		break
	elif sb == True:
		s = mid + 1
	else:
		e = mid - 1


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.append(10 ** 57)
m = n // 2
for i in range(m, n):
	p = (i - m + 1) * (a[i + 1] - a[i])
	if k < p:
		break
	k -= p
print(a[i] + k // (i - m + 1))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
mid = n // 2

def predicate(x):
	add = 0
	for i in range(mid, n):
		add += max(x - arr[i], 0)
	return add <= k

def bs(start, end):
	ans = None
	while start <= end:
		mid = start + end >> 1
		if predicate(mid):
			ans = mid
			start = mid + 1
		else:
			end = mid - 1
	return ans
ans = bs(0, 2 * pow(10, 9) + 100)
print(ans)


n = list(map(int, input().split()))
in_arr = [int(x) for x in input().split()]
in_arr.sort()
arr = []
for i in range(int(n[0] / 2), n[0]):
	arr.append(in_arr[i])
l = 0
r = 10000000001
while r - l > 1:
	mid = int((r + l) / 2)
	total = 0
	for i in arr:
		total += max(0, mid - i)
	if total <= n[1]:
		l = mid
	else:
		r = mid
print(l)


[n, k] = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
ps = [0]
for i in range(n):
	ps.append(ps[-1] + a[i])
ans = 0
for i in range(n // 2, n):
	ts = ps[i + 1] - ps[n // 2]
	ts = ts + k
	avg = ts // (i - n // 2 + 1)
	try:
		if avg > a[i + 1]:
			continue
		else:
			ans = avg
			break
	except:
		ans = avg
		continue
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
i = 0
s = 0
d = n // 2 + 1
res = l[n // 2]
for j in range(n // 2 + 1, n):
	i += 1
	if k >= i * (l[j] - l[j - 1]):
		s += i * (l[j] - l[j - 1])
		k -= i * (l[j] - l[j - 1])
		res += l[j] - l[j - 1]
	else:
		d = i
		break
if k // d != 0:
	res += k // d
print(res)


(n, k) = map(int, input().split())
q = sorted(map(int, input().split()))[int(n / 2):n]
median = q[0]
op = 1
for i in range(1, len(q)):
	if (q[i] - median) * op <= k:
		k -= (q[i] - median) * op
		median = q[i]
	else:
		break
	op += 1
print(median + int(k / op))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mid = n // 2
count = 1
Sum = a[mid]
res = a[mid]
index = -1
for i in range(mid + 1, n):
	if count * a[i] - Sum <= k:
		count += 1
		Sum += a[i]
		res = a[i]
	else:
		index = i
		break
if index == -1:
	k = max(0, k - (count * a[-1] - Sum))
	res += k // (mid + 1)
	print(res)
else:
	k = max(0, k - (count * a[index - 1] - Sum))
	res += k // (index - mid)
	print(res)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, k) = LI()
		a = LI()
		a.sort()
		a.append(inf)
		i = n // 2
		t = a[i]
		c = 1
		while k >= c:
			m = a[i + 1] - t
			if m == 0:
				c += 1
				i += 1
				continue
			u = min(m, k // c)
			if u == 0:
				break
			t += u
			k -= u * c
			c += 1
			i += 1
		rr.append(t)
	return JA(rr, '\n')
print(main())


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
sum = 0
cnt = 0
ans = arr[n // 2]
for i in range(n // 2, n):
	sum += arr[i]
	cnt += 1
	check = (sum + k) // cnt
	if check >= arr[i] and i == n - 1:
		ans = max(ans, check)
		break
	if check >= arr[i] and check <= arr[i + 1]:
		ans = max(ans, check)
print(ans)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
if n < 2:
	print(a[0] + k)
	exit()
i = n // 2
while k >= (i - n // 2 + 1) * (a[i + 1] - a[i]):
	diff = (i - n // 2 + 1) * (a[i + 1] - a[i])
	if diff:
		k -= diff
		a[n // 2:i + 1] = [a[i + 1]] * (i - n // 2 + 1)
	i += 1
	if i > n - 2:
		break
print(a[n // 2] + k // (i - n // 2 + 1))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 1
jog = 0
ans = 0
if n == 1:
	print(a[0] + k)
else:
	for i in range(int((n - 1) / 2), n - 1):
		jog += l * (a[i + 1] - a[i])
		if jog > k:
			jog -= l * (a[i + 1] - a[i])
			ans = a[i] + int((k - jog) / l)
			break
		l += 1
	if ans != 0:
		print(ans)
	else:
		ans = a[i + 1] + int((k - jog) / l)
		print(ans)


(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
arr.sort()
arr_size = len(arr)
arr_start = int(arr_size / 2)
if n == 1:
	flag = True
else:
	flag = False
m = 1
sum_k = 0
max_num = arr[arr_start]
while arr_start < arr_size - 1:
	temp = arr[arr_start + 1] - arr[arr_start]
	sum_k = sum_k + temp * m
	max_num = max_num + temp
	if sum_k > k:
		if (sum_k - k) % m:
			max_num -= int((sum_k - k) / m) + 1
		else:
			max_num -= int((sum_k - k) / m)
		break
	if sum_k == k:
		break
	m += 1
	arr_start += 1
	if arr_start == arr_size - 1:
		flag = True
if flag:
	max_num += int((k - sum_k) / m)
print(max_num)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
j = 0
r = n // 2
cnt = 1
ans = 0
u = 0
for i in range(r + 1, n):
	value = cnt * (a[i] - a[i - 1])
	if value < k:
		k -= value
	elif value == k:
		j = 1
		ans = a[i]
		break
	else:
		ans = a[i - 1] + k // cnt
		u = 1
		break
	cnt += 1
if j != 1 and u != 1:
	ans = a[n - 1] + k // (n - r)
if j == 1:
	print(ans)
elif u == 1:
	print(ans)
else:
	print(ans)


(n, k) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
a.sort()
a = a[n // 2:] + [10 ** 10]
for i in range(1, len(a)):
	prev = a[i - 1]
	curr = a[i]
	if (curr - prev) * i <= k:
		a[0] = curr
		k -= (curr - prev) * i
	else:
		val = k // i
		a[0] += val
		break
print(a[0])


(n, k) = list(map(int, input().split()))
arr = sorted(list(map(int, input().split())))
median = arr[n // 2]
jumps = []
for i in range(n // 2 + 1, n):
	jumps.append(arr[i] - arr[i - 1])
for i in range(len(jumps)):
	weight = i + 1
	if weight * jumps[i] > k:
		this_jump = k // weight
		median += this_jump
		k -= this_jump * weight
		break
	k -= weight * jumps[i]
	median += jumps[i]
weight = n // 2 + 1
median += k // weight
print(median)


(n, k) = map(int, input().split())
l = [float('inf')] + sorted(map(int, input().split())) + [float('inf')]
i = n // 2 + 2
I = (n + 1) // 2
cnt = 1
while k:
	while l[I] == l[i]:
		i += 1
		cnt += 1
	d = min((l[i] - l[I]) * cnt, k)
	l[I] += d // cnt
	k -= d
print(l[I])


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, k) = iia()
arr = sorted(iia())[n // 2:]
cnt = 1
for i in range(len(arr) - 1):
	t = (arr[i + 1] - arr[i]) * cnt
	if t <= k:
		k -= t
		arr[i] = arr[i + 1]
		cnt += 1
	else:
		print(arr[i] + k // cnt)
		break
else:
	print(arr[-1] + k // cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 1
r = 2000000000

def c(x):
	ans = 0
	for i in range(n // 2, n):
		ans += max(0, x - a[i])
	return ans
while l != r:
	m = (l + r + 1) // 2
	if c(m) <= k:
		l = m
	else:
		r = m - 1
print(l)


(n, k) = input().split()
intn = int(n)
intk = int(k)
a = list(map(int, input().strip().split()))[:intn]
a.sort()
l = 2000000000
s = 0
ans = 0
while s <= l:
	mid = (s + l) // 2
	su = 0
	for i in range(intn // 2, intn):
		su = su + max(0, mid - a[i])
	if su > intk:
		l = mid - 1
	else:
		ans = mid
		s = mid + 1
print(ans)


from sys import stdin
input = stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
ans = l[n // 2]
x = l[n // 2]
md = x
t = 0
for i in range(n // 2, n):
	t += 1
	if l[i] != md or i == n - 1:
		if k >= (t - 1) * (l[i] - md):
			ans += l[i] - md
			k -= (t - 1) * (l[i] - md)
			md = l[i]
		else:
			ans += k // (t - 1)
			break
	if l[i] == md and i == n - 1:
		ans += k // t
print(ans)


def can(x):
	cnt = 0
	for i in range(n // 2, n):
		cnt += max(0, x - arr[i])
	if cnt <= k:
		return True
	else:
		return False
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if n == 1:
	print(arr[0] + k)
else:
	l = arr[n // 2]
	r = arr[n // 2] + k
	ans = arr[n // 2]
	while l <= r:
		mid = (l + r) // 2
		if can(mid):
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	print(ans)


def main():
	import sys
	input = sys.stdin.readline
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	arr.append(10 ** 12)
	median = arr[n >> 1]
	i = n // 2
	while i <= n - 1 and arr[i + 1] == median:
		i += 1
	cnt = i + 1 - n // 2
	while i <= n:
		i += 1
		while i <= n - 1 and arr[i + 1] == arr[i]:
			i += 1
		diff = arr[i] - median
		if diff * cnt > k:
			ans = median + k // cnt
			break
		else:
			median += diff
			k -= cnt * diff
			cnt = i + 1 - n // 2
	print(ans)
	return 0
main()


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))[n // 2:]
i = 0
s = 0
while i < len(a):
	s += a[i]
	if a[i] * (i + 1) - s > k:
		break
	i += 1
k -= a[i - 1] * i - sum(a[:i])
print(a[i - 1] + k // i)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = n // 2
p = a[m]
t = k
c = 1
for i in range(m + 1, n):
	d = a[i] - p
	r = t - c * d
	if r == 0:
		print(a[i])
		exit()
	elif r < 0:
		print(a[i - 1] + t // c)
		exit()
	else:
		c += 1
		p = a[i]
		t = r
print(a[n - 1] + t // c)


(a, b) = map(int, input().split())
z = sorted(map(int, input().split()))

def ok(mid):
	clk = 0
	for i in range(a // 2, a):
		clk += max(0, mid - z[i])
		if clk > b:
			return False
	return True

def bin_s():
	(lo, hi, ans) = (1, 2 * int(1000000000.0), 0)
	while lo <= hi:
		mid = (lo + hi) // 2
		if ok(mid):
			ans = mid
			lo = mid + 1
		else:
			hi = mid - 1
	return ans
print(bin_s())


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.insert(0, 0)

def F(m):
	s = 0
	for i in range(n // 2 + 1, n + 1):
		s += max(0, m - a[i])
	return s <= k
l = a[n // 2 + 1]
r = 100000000000
while l <= r:
	m = (l + r) // 2
	if F(m):
		res = m
		l = m + 1
	else:
		r = m - 1
print(res)


import sys
from fractions import gcd
from math import ceil, sqrt, sin, pi, tan
from collections import defaultdict
read = sys.stdin.buffer.readline
import heapq
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())
as0 = ord('0')
as1 = ord('1')
for _ in range(1):
	(n, k) = mi()
	a = li()
	a.sort()
	ans = a[n // 2]
	(l, h) = (0, 2000000000)
	while l <= h:
		x = (l + h) // 2
		nop = 0
		for i in range(n // 2 + 1):
			nop += max(0, x - a[n - 1 - i])
		if nop <= k:
			ans = max(ans, x)
			l = x + 1
		else:
			h = x - 1
	print(ans)


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
(n, k) = INL()
A = sorted(INL())
ans = A[n // 2]
for _ in range(n // 2 + 1, n):
	if A[_] != A[_ - 1]:
		if k >= (A[_] - A[_ - 1]) * (_ - n // 2):
			k -= (A[_] - A[_ - 1]) * (_ - n // 2)
			ans += A[_] - A[_ - 1]
		else:
			ans += k // (_ - n // 2)
			break
else:
	ans = A[-1] + k // (n - n // 2)
OPS(ans)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import math
from bisect import bisect_left
(n, k) = getList()
nums = getList()
nums.sort()
half = n // 2 + 1
nums = nums[half - 1:]
sm = sum(nums)

def check(arr, k, tgt):
	for num in arr:
		sub = max(0, tgt - num)
		if sub == 0:
			return True
		k -= sub
		if k < 0:
			return False
	return True
mn = 0
mx = 3 * 10 ** 9
while mx - mn > 1:
	md = (mx + mn) // 2
	if check(nums, k, md):
		mn = md
	else:
		mx = md
if not check(nums, k, md):
	md -= 1
print(md)


def main():
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = [int(i) for i in input().split()]
	a.sort()
	mid = int(n / 2)
	for i in range(mid + 1, n):
		if a[mid] < a[i]:
			diff = a[i] - a[mid]
			if (i - mid) * diff >= k:
				print(a[mid] + int(k / (i - mid)))
				return
			else:
				a[mid] += diff
				k -= (i - mid) * diff
	print(a[mid] + int(k / (mid + 1)))
main()


import bisect
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr.sort()
cmedian = arr[n // 2]
curr = n // 2
to_increase = 0
ans = 0
while True:
	x = bisect.bisect_right(arr, cmedian)
	to_increase += x - curr
	if x < n:
		by_increase = arr[x] - arr[curr]
		if by_increase * to_increase > k:
			by_increase = k // to_increase
			cmedian += by_increase
			ans = cmedian
			break
		else:
			k -= by_increase * to_increase
			cmedian = arr[x]
			curr = x
	else:
		by_increase = k // to_increase
		cmedian += by_increase
		ans = cmedian
		break
print(ans)


(n, k) = map(int, input().split())
m = [int(a) for a in input().split()]
m.sort()
del m[0:n // 2]
n = len(m)
a = 1
while k > 0:
	if a < n and k - a * (m[a] - m[0]) >= 0:
		k = k - a * (m[a] - m[0])
		m[0] += m[a] - m[0]
		a += 1
	else:
		m[0] += k // a
		k = 0
print(m[0])


import bisect
(n, k) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
l.sort()
mid = n // 2
if n == 1:
	print(l[0] + k)
else:
	r = []
	for i in range(mid, n - 1):
		r.append((i - mid + 1) * (l[i + 1] - l[i]))
	dp = [r[0]]
	for i in range(1, len(r)):
		dp.append(r[i] + dp[i - 1])
	if k < dp[-1]:
		idx = bisect.bisect_left(dp, k)
		if idx != 0:
			k -= dp[idx - 1]
			start = l[n // 2:][idx]
			destination = l[n // 2:][idx + 1]
			step_size = idx + 1
			d = k // step_size
			start += d
			print(start)
		else:
			print(l[mid] + k)
	else:
		k -= dp[-1]
		print(l[-1] + k // (n // 2 + 1))


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
a += [10 ** 10]
m = (n - 1) // 2
med = 0
sum1 = 0
for i in range(m, n):
	sum1 += a[i]
	c = min(a[i + 1], (k + sum1) // (i + 1 - m))
	if c < a[i]:
		break
	if c > med:
		med = c
print(med)


def check(m):
	dif = lista[n // 2] + m
	soma = 0
	for x in lista[n // 2:]:
		soma += max(0, dif - x)
	return soma <= k
(n, k) = [int(i) for i in input().split()]
lista = [int(i) for i in input().split()]
lista.sort()
l = 0
r = 1000000001
while l < r:
	mid = (l + r + 1) // 2
	if check(mid):
		l = mid
	else:
		r = mid - 1
print(l + lista[n // 2])


import sys
import math
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
import heapq
infinite = float('inf')
(n, k) = RI()
l = RI()
l.sort()
i = n // 2
median = l[i]
steps = 0
count = 0
while i < n:
	temp = l[i]
	while i < n and l[i] == temp:
		count += 1
		i += 1
	if i < n:
		a = k // count
		if a == 0:
			break
		else:
			diff = l[i] - temp
			if a >= diff:
				k -= diff * count
				median = l[i]
				continue
			else:
				k -= a * count
				median += a
				break
	else:
		a = k // count
		if a == 0:
			break
		else:
			median += a
			break
print(median)


(n, k) = list(map(int, input().split()))[:2]
a = list(map(int, input().split()))
a = sorted(a)
b = a[n // 2:]
diff = []
for i in range(1, len(b)):
	di = i * (b[i] - b[i - 1])
	diff.append(di)
ans = b[0]
for i in range(len(diff)):
	if k < diff[i]:
		ans = ans + k // (i + 1)
		k = 0
		break
	else:
		k -= diff[i]
		ans = b[i + 1]
ans = ans + k // len(b)
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mid = int(n / 2)
up = mid + 1
while k > 0:
	if up >= n:
		k -= n - mid
		a[mid] += 1
	elif a[up] == a[mid]:
		up += 1
	else:
		k -= up - mid
		a[mid] += 1
if k == 0:
	print(a[mid])
else:
	print(a[mid] - 1)


[n, k] = [int(w) for w in input().split()]
a = [int(w) for w in input().split()]
a.sort()
a.append(10 ** 57)
m = n // 2
for i in range(m, n):
	dk = (i - m + 1) * (a[i + 1] - a[i])
	if k < dk:
		break
	k -= dk
print(a[i] + k // (i - m + 1))


from sys import stdin
input = stdin.readline
from collections import deque
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
(n, k) = R()
a = sorted(R()) + [10 ** 12 + 7]
m = a[n // 2]
r = 1
for i in a[n // 2 + 1:]:
	if i != m:
		v = min(k, (i - m) * r)
		k -= v
		m += v // r
	r += 1
	if not k:
		break
print(m)


l = input().split()
n = int(l[0])
k = int(l[1])
l = input().split()
li = [int(i) for i in l]
li.append(1000000000000)
li.sort()
curr = n // 2
slot = 1
ans = li[curr]
while 1:
	possible = (li[curr + 1] - li[curr]) * slot
	if k >= possible:
		ans = li[curr + 1]
		curr += 1
		slot += 1
		k -= possible
	else:
		ans += k // slot
		break
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
ans = l[n // 2]
x = l[n // 2]
md = x
t = 0
for i in range(n // 2, n):
	t += 1
	if l[i] != md or i == n - 1:
		if k >= (t - 1) * (l[i] - md):
			ans += l[i] - md
			k -= (t - 1) * (l[i] - md)
			md = l[i]
		else:
			ans += k // (t - 1)
			break
	if l[i] == md and i == n - 1:
		ans += k // t
print(ans)


from bisect import bisect_left

def binarySearch(a, lo, hi, x, func):
	ans = -1
	while lo <= hi:
		mid = (lo + hi) // 2
		val = func(a, mid)
		if val == x:
			ans = mid
			hi = mid - 1
		elif val > x:
			hi = mid - 1
		else:
			lo = mid + 1
	return ans if ans != -1 else lo - 1

def func(arr, v):
	sum = 0
	for d in arr:
		sum += max(0, v - d)
	return sum

def main():
	(n, m) = [int(v) for v in input().split()]
	val = [int(v) for v in input().split()]
	val.sort()
	v = int(2000000000.0)
	res = binarySearch(val[len(val) // 2:], 0, v, m, func)
	print(res)
main()


def check(x, n, a, k):
	mov = 0
	for i in range(n // 2, n, 1):
		if x - a[i] > 0:
			mov += x - a[i]
		if mov > k:
			return False
	if mov <= k:
		return True
	else:
		return False

def bin(a, n, k):
	s = 1
	b = 2000000000
	a.sort()
	while s != b:
		mid = (s + b + 1) // 2
		if check(mid, n, a, k):
			s = mid
		else:
			b = mid - 1
	print(s)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
bin(a, n, k)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
min_index = (n + 1) // 2 - 1
Min = lst[min_index]
Max = Min + k
flag = 0
while Min <= Max:
	mid = (Min + Max) // 2
	total = 0
	for i in range(min_index, n):
		temp = mid - lst[i]
		if temp > 0:
			total += temp
	if total == k:
		print(mid)
		flag = 1
		break
	if total < k:
		Min = mid + 1
	else:
		Max = mid - 1
if flag == 0:
	print(Max)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
r = k
m = (n - 1) // 2
p = m + 1
v = a[m]
while p < n:
	u = (p - m) * (a[p] - v)
	if u <= r:
		v = a[p]
		r -= u
	else:
		break
	p += 1
d = r // (p - m)
u = d * (p - m)
r -= u
v = v + d
print(v)


def bi(a, x):
	l = -1
	u = len(a)
	while u - l > 1:
		md = int((l + u) / 2)
		if x >= a[md]:
			l = md
		else:
			u = md
	return u - 1
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
diff = [0] * (n // 2 + 1)
for i in range(1, n // 2 + 1):
	diff[i] = (a[i + n // 2] - a[i + n // 2 - 1]) * i + diff[i - 1]
index = bi(diff, k)
print(a[n // 2 + index] + (k - diff[index]) // (index + 1))


(N, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

def calc(x):
	num = 0
	for i in range(N // 2, N):
		num += max(x - a[i], 0)
		if num > k:
			return False
	return num <= k
(l, r) = (0, 10 ** 9 * 3)
while r - l > 1:
	mid = (l + r) // 2
	if calc(mid):
		l = mid
	else:
		r = mid
print(l)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
b.sort()
m = b[(n - 1) // 2]
j = (n - 1) // 2
p = 1
while j < n - 1:
	if k >= p * (b[j + 1] - b[j]):
		m = b[j + 1]
		k += -p * (b[j + 1] - b[j])
		p += 1
		j += 1
	else:
		break
print(m + k // p)


def check(mid):
	ans = 0
	for i in range(n // 2 + 1):
		ans += max(0, mid - a[i])
	if ans <= k:
		return True
	return False
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
(l, r) = (1, 10 ** 10)
while l != r:
	mid = (l + r + 1) // 2
	if check(mid):
		l = mid
	else:
		r = mid - 1
print(l)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
MOD = pow(10, 9) + 7
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')

def binary_search(data, val, le):
	test = le
	if val >= data[-1]:
		return [test - 1, test - 1]
	elif val <= data[0]:
		return [0, 0]
	high_index = test - 1
	low_index = 0
	while high_index > low_index:
		index = (high_index + low_index) // 2
		sub = data[index]
		if data[low_index] == val:
			return [low_index, low_index]
		elif sub == val:
			return [index, index]
		elif data[high_index] == val:
			return [high_index, high_index]
		elif sub > val:
			if high_index == index:
				return sorted([high_index, low_index])
			high_index = index
		else:
			if low_index == index:
				return sorted([high_index, low_index])
			low_index = index
	return sorted([high_index, low_index])
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
l.sort()
x = n // 2
val = l[x]
i = 1
while x < n - 1:
	x += 1
	to_add = i * (l[x] - val)
	if k - to_add < 0:
		val += k // i
		k = 0
		break
	k -= to_add
	val = l[x]
	i += 1
if k:
	val += k // i
print(val)


(n, m) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
arr.sort()
mid = n // 2
dp = [0] * n
half = 0
for i in range(mid, n):
	if i == mid:
		dp[i] = arr[i] + m
		half += dp[i]
	else:
		dp[i] = arr[i]
		if dp[i] >= dp[i - 1]:
			break
		else:
			div = i - mid + 1
			half += dp[i]
			dp[i] = half // div
			dp[mid] = half // div
			rem = half % div
			dp[i] += 1
print(dp[mid])


from math import ceil
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
z = n // 2
ans = l[z]
count = 1
for i in range(z, n - 1):
	if l[i] != l[i + 1]:
		m = l[i + 1] - l[i]
		if k >= m * count:
			k -= m * count
			ans = l[i + 1]
			l[z] += m
		else:
			if k >= count:
				l[z] += k // count
			k = 0
			break
	count += 1
if k >= ceil(n / 2):
	print(l[z] + k // ceil(n / 2))
else:
	print(l[z])


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
idxAns = int(n / 2)
ans = arr[idxAns]
while k > 0:
	idx = idxAns + 1
	while idx < n:
		if ans != arr[idx]:
			break
		idx += 1
	if idx == n:
		x = n - idxAns
		ans += int(k / x)
		k = 0
	else:
		minimum = min(k, (arr[idx] - ans) * (idx - idxAns))
		if minimum == k and minimum == (arr[idx] - ans) * (idx - idxAns):
			ans += arr[idx] - ans
		elif minimum == (arr[idx] - ans) * (idx - idxAns):
			for i in range(idxAns, idx):
				arr[i] += arr[idx] - ans
			ans = arr[idxAns]
		else:
			ans += int(k / (idx - idxAns))
		k -= minimum
print(ans)


l = [int(i) for i in input().split(' ')]
n = l[0]
k = l[1]
l = [int(i) for i in input().split(' ')]
l = sorted(l)
med = (n - 1) // 2
val = l[med]
end = False
vl = 0
s = 1
vals = []
for i in range(med + 1, len(l)):
	if l[i] == l[i - 1]:
		s += 1
		continue
	knum = s
	if k >= (l[i] - l[i - 1]) * s:
		k -= (l[i] - l[i - 1]) * s
		vl += l[i] - l[i - 1]
	else:
		vl += k // s
		k = k % s
		break
	s += 1
vl += k // s
print(vl + val)


temp = input()
temp = temp.split(' ')
n = int(temp[0])
k = int(temp[1])
temp = input()
temp = temp.split(' ')
a = []
for i in range(n):
	a.append(int(temp[i]))
a.sort()
mid = int(n / 2)
move = 0
j = mid
i = mid + 1
while i < n:
	if move + (a[i] - a[i - 1]) * (i - mid) <= k:
		move = move + (a[i] - a[i - 1]) * (i - mid)
		j = i
	else:
		break
	i += 1
left = k - move
ans = a[j]
ans += int(left / (j - mid + 1))
print(ans)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
if n == 1:
	print(a[0] + k)
	exit()
y = n // 2
ans = a[y]
while True:
	for y in range(y + 1, n):
		if a[y] != ans:
			break
	else:
		r = n - n // 2
		ans += k // r
		print(ans)
		break
	r = y - n // 2
	if ans + k // r >= a[y]:
		k -= (a[y] - ans) * r
		ans = a[y]
	else:
		ans += k // r
		print(ans)
		break


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
if n == 1:
	print(a[0] + k)
else:
	a.sort()
	x = n // 2
	if a[x] + k <= a[x + 1]:
		print(a[x] + k)
	else:
		nextelem = x + 1
		countelem = 1
		incer = 0
		prev = a[x]
		while nextelem < n:
			diff = a[nextelem] - prev
			if k >= countelem * diff:
				k = k - countelem * diff
				incer = incer + diff
				prev = a[nextelem]
				nextelem = nextelem + 1
				countelem = countelem + 1
			else:
				break
		if k > 0:
			incer = incer + k // countelem
		print(a[x] + incer)


(n, k) = map(int, input().split())
s = sorted(map(int, input().split()))
j = n // 2
i = n // 2
m = s[i]

def meadian(i, j, m, s, k):
	while i < n - 1:
		t = (s[i + 1] - m) * (i + 1 - j)
		if t <= k:
			k -= t
			m = s[i + 1]
		else:
			break
		i += 1
	return m + k // (i + 1 - j)
print(meadian(i, j, m, s, k))


import sys
from collections import defaultdict

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	pos = len(a) // 2
	lo = a[pos]
	hi = 3 * 10 ** 9
	while lo + 1 < hi:
		mid = (lo + hi) // 2
		ops = sum((max(0, mid - a[i]) for i in range(pos, len(a))))
		if ops > k:
			hi = mid
		else:
			lo = mid
	if sum((max(0, hi - a[i]) for i in range(pos, len(a)))) <= k:
		lo = hi
	print(lo)
main()


import bisect
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
h = len(l)
xs = n // 2
i = xs
ans = l[xs]
while i < h:
	ys = bisect.bisect_right(l, l[i], i, h)
	ind = ys - xs
	if ys < h:
		diff = l[ys] - l[i]
		x = diff * ind
		if x < k:
			k -= x
			ans = l[ys]
			i = ys
		elif x == k:
			ans = l[ys]
			break
		else:
			bx = k // ind
			ans += bx
			break
	else:
		bx = k // ind
		ans += bx
		break
print(ans)


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

def rints():
	return list(map(int, input().split()))
(n, k) = rints()
a = rints()
a.sort()
c = 1
m = a[n // 2]
while c <= n // 2 and k > 0:
	ne = a[n // 2 + c]
	if (ne - m) * c > k:
		break
	k -= (ne - m) * c
	m = ne
	c += 1
print(m + k // c)


(n, k) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
(l, u) = (0, 2000000000.0)
m = -1
while l != u:
	m = (l + u + 1) // 2
	s = 0
	for i in range(n // 2, n):
		s += max(0, m - a[i])
	if s > k:
		u = m - 1
	else:
		l = m
print(int(l))


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a = sorted(a)

def check(x):
	req = 0
	for i in range(n // 2, n):
		req += max(0, x - a[i])
	return req <= k
low = a[n // 2]
high = 10 ** 15
ans = -1
while low <= high:
	mid = (low + high) // 2
	if check(mid):
		ans = mid
		low = mid + 1
	else:
		high = mid - 1
print(ans)


(n, m) = [int(x) for x in input().split()]
arrs = sorted([int(x) for x in input().split()])[n // 2:]
left = 0
rite = 10 ** 10
while rite - left > 1:
	mid = (left + rite) // 2
	need = 0
	for vals in arrs:
		need += max(0, mid - vals)
	if need > m:
		rite = mid
	else:
		left = mid
print(left)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
res = a[n // 2]
for i in range(n // 2 + 1, n):
	d = min(a[i] - res, k // (i - n // 2))
	res += d
	k -= d * (i - n // 2)
res += k // (n // 2 + 1)
print(res)


(n, k) = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
Fixed = n // 2
i = n // 2 + 1
if n == 1:
	print(A[0] + k)
	exit()
if k - (i - Fixed) * (A[i] - A[Fixed]) < 0:
	print(A[Fixed] + k)
	exit()
x = 0
while 1:
	if k - (i - Fixed) * (A[i] - A[Fixed]) < 0:
		x = k // (i - Fixed)
		break
	k -= (i - Fixed) * (A[i] - A[Fixed])
	A[Fixed] = A[i]
	i += 1
	if i == n:
		x = k // (n // 2 + 1)
		break
print(A[Fixed] + x)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
mid = (n - 1) // 2
while k > 0:
	i = mid
	while i < n and a[i] == a[mid]:
		i += 1
	res = i - mid
	if res == 0:
		k -= a[mid + 1]
		if k >= 0:
			a[mid] = a[mid + 1]
		else:
			a[mid] += k
			break
	elif k >= res and i == n:
		val = k // res
		a[mid] += val
		break
	elif k >= res:
		val = a[i] - a[mid]
		mo = k // res
		if mo <= val:
			a[mid] += mo
			break
		else:
			for j in range(mid, i):
				a[j] += val
			k -= val * res
	else:
		break
print(a[mid])


x = input().split()
n = input().split()
for i in range(0, len(n)):
	n[i] = int(n[i])
moves = int(x[1])
n.sort()
medianIndex = int(len(n) / 2)
median = n[medianIndex]
maxi = int(n[-1]) + moves
medmid = 0
tots = 0
while median <= maxi:
	medmid = int((median + maxi) / 2)
	total = 0
	for i in range(medianIndex, len(n)):
		if medmid > n[i]:
			total += medmid - n[i]
	if total <= moves:
		tots = medmid
		median = medmid + 1
	else:
		maxi = medmid - 1
print(tots)


line = input()
tmp1 = line.split(' ')
(n, m) = (int(tmp1[0]), int(tmp1[1]))
line1 = input()
num = [int(i) for i in line1.split(' ')]
num = sorted(num)
j = n // 2
r = n // 2 + 1
while m and r < n:
	if num[j] == num[r]:
		r += 1
	else:
		t = min(m, (num[r] - num[j]) * (r - j))
		num[j] += t // (r - j)
		m -= t
if num[j] == num[n - 1]:
	print(num[j] + m // (n - j))
else:
	print(num[j] + min(m, (num[r] - num[j]) * (r - j)) // (r - j))


(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split())))
count = a[n // 2]
num = 1
for i in range(n // 2 + 1, n):
	if (a[i] - count) * num <= k:
		k -= (a[i] - count) * num
		count = a[i]
	else:
		break
	num += 1
print(count + k // num)


def func(y, n, k, arr):
	oper = 0
	for i in range(n // 2, n):
		if arr[i] < y:
			oper += y - arr[i]
		else:
			break
	return oper <= k
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
l = arr[n // 2]
r = arr[n // 2] + k + 1
while l + 1 < r:
	mid = (l + r) // 2
	if func(mid, n, k, arr):
		l = mid
	else:
		r = mid
print(l)


(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
ar.sort()
med = ar[(n - 1) // 2]
flag = True
for (i, j) in enumerate(range((n + 1) // 2, n), 1):
	pr = ar[j] - ar[j - 1]
	if k >= pr * i:
		med = ar[j]
		k -= pr * i
	elif pr != 0:
		med = ar[j - 1] + k // i
		flag = False
		break
if flag:
	med = ar[-1] + k // ((n + 1) // 2)
print(med)


def check(g):
	s = 0
	for i in range(int(n / 2), n):
		if a[i] < g:
			s += g - a[i]
	if s <= k:
		return 1
	return 0
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = 1
c = 10 ** 15
while d <= c:
	g = int((d + c) / 2)
	if check(g) == 1:
		res = g
		d = g + 1
	else:
		c = g - 1
print(res)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
t = len(a) // 2
max = a[t]
klast = 1
while k > 0 and t + 1 < len(a):
	k1 = (a[t + 1] - a[t]) * klast
	if k >= k1:
		k -= k1
		max = a[t + 1]
	else:
		break
	t += 1
	klast += 1
if k > 0:
	max += k // klast
print(max)