There are $n$ benches in the Berland Central park. It is known that $a_i$ people are currently sitting on the $i$-th bench. Another $m$ people are coming to the park and each of them is going to have a seat on some bench out of $n$ available.

Let $k$ be the maximum number of people sitting on one bench after additional $m$ people came to the park. Calculate the minimum possible $k$ and the maximum possible $k$.

Nobody leaves the taken seat during the whole process.


-----Input-----

The first line contains a single integer $n$ $(1 \le n \le 100)$ — the number of benches in the park.

The second line contains a single integer $m$ $(1 \le m \le 10\,000)$ — the number of people additionally coming to the park.

Each of the next $n$ lines contains a single integer $a_i$ $(1 \le a_i \le 100)$ — the initial number of people on the $i$-th bench.


-----Output-----

Print the minimum possible $k$ and the maximum possible $k$, where $k$ is the maximum number of people sitting on one bench after additional $m$ people came to the park.


-----Examples-----
Input
4
6
1
1
1
1

Output
3 7

Input
1
10
5

Output
15 15

Input
3
6
1
6
5

Output
6 12

Input
3
7
1
6
5

Output
7 13



-----Note-----

In the first example, each of four benches is occupied by a single person. The minimum $k$ is $3$. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining — the fourth bench. The maximum $k$ is $7$. That requires all six new people to occupy the same bench.

The second example has its minimum $k$ equal to $15$ and maximum $k$ equal to $15$, as there is just a single bench in the park and all $10$ people will occupy it.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Implementation


Solutions:
n = int(input())
m = int(input())
a = []
for i in range(n):
	t = int(input())
	a.append(t)
maxi = max(a)
Kmax = maxi + m
d = 0
for k in range(n):
	d += maxi - a[k]
if m <= d:
	Kmin = maxi
elif (m - d) % n == 0:
	Kmin = (m - d) // n + maxi
else:
	Kmin = (m - d) // n + maxi + 1
print(Kmin, Kmax)


def ii():
	return int(input())
(k, m) = (ii(), ii())
l = []
for i in range(k):
	l.append(ii())
res = [0] * 2
res[0] = max(l) + m
i = 0
while i < m:
	l[l.index(min(l))] += 1
	i += 1
res[1] = max(l)
res.reverse()
print(*res)


import math
n = int(input())
m = int(input())
a = list()
maxx = 0
summ = 0
for i in range(n):
	a.append(int(input()))
	if a[i] > maxx:
		maxx = a[i]
for i in range(n):
	summ += abs(a[i] - maxx)
print(maxx if summ > m else maxx + math.ceil((m - summ) / n), maxx + m)


def lavochki(n, m, lst):
	mx = max(lst) + m
	while m:
		ind = min(list(range(n)), key=lambda j: lst[j])
		lst[ind] += 1
		m -= 1
	return (max(lst), mx)
N = int(input())
M = int(input())
a = list()
for i in range(N):
	elem = int(input())
	a.append(elem)
print(*lavochki(N, M, a))


n = int(input())
m = int(input())
l = []
for i in range(0, n):
	l.append(int(input()))
r2 = max(l)
for i in range(0, m):
	r1 = l.index(min(l))
	l[r1] += 1
r1 = max(l)
print(r1, r2 + m)


n = int(input())
m = int(input())
a = []
s = 0
for i in range(n):
	a.append(int(input()))
k = max(a)
for i in range(n):
	s = s + k - a[i]
l = 0
if s > m:
	l = k
else:
	l = k + (m - s + n - 1) // n
print(l, k + m)


import sys
n = int(sys.stdin.readline())
m = int(sys.stdin.readline())
arr = []
for _ in range(n):
	arr.append(int(sys.stdin.readline()))
val = max(arr)
max_m = val + m
min_m = m
temp = 0
for i in range(n):
	temp += abs(val - arr[i])
min_m -= temp
if min_m > 0:
	print(val + min_m // n if min_m % n == 0 else val + min_m // n + 1, max_m)
else:
	print(val, max_m)


n = int(input())
m = int(input())
min_seat = 0
max_seat = 0
total_seat = 0
for i in range(n):
	current_seat = int(input())
	total_seat += current_seat
	if current_seat > max_seat:
		max_seat = current_seat
(mean_seat, mod) = divmod(total_seat + m, n)
print(max(max_seat, mean_seat + (1 if mod else 0)), max_seat + m)


n = int(input())
m = int(input())
benches = []
while n > 0:
	benches.append(int(input()))
	n -= 1
maximum = max(benches)
total = sum(benches)
target = len(benches) * maximum
remainder = total + m - target
if remainder <= 0:
	print(maximum, maximum + m)
else:
	minimum = remainder // len(benches)
	if remainder % len(benches):
		minimum += 1
	print(maximum + minimum, maximum + m)


import sys

def minp():
	return sys.stdin.readline().strip()
n = int(minp())
m = int(minp())
a = [0] * 101
z = 0
r = 0
for i in range(n):
	x = int(minp())
	a[x] += 1
	z = max(z, x)
	r += x
M = z + m
if z * n - r >= m:
	mm = z
else:
	m -= z * n - r
	mm = z + (m + n - 1) // n
print(str(mm) + ' ' + str(M))


n = int(input())
man = int(input())
m = list()
for x in range(n):
	a = int(input())
	m.append(a)
b = max(m)
su = list()
for i in m:
	e = b - i
	su.append(e)
su = sum(su)
su = man - su
if su < 0:
	su = b
elif su % n == 0:
	su = b + int(su / n)
else:
	su = b + int(su / n) + 1
print('{:d} {:d}'.format(su, b + man))


n = int(input())
m = int(input())
s = [int(input()) for _ in range(n)]
ma = max(s) + m
s = sorted(s)
pp = max(s)
for (i, e) in enumerate(s):
	s[i] += pp - e
	m -= pp - e
	if m < 0:
		t = abs(m)
		s[i] -= t
	if m <= 0:
		break
mi = max(s)
if m > 0:
	mi = s[0] + m // len(s) + (1 if m % len(s) != 0 else 0)
print(mi, ma)


n = int(input())
m = int(input())
q = []
for i in range(n):
	q += [int(input())]
z = max(q)
for i in range(m):
	q[q.index(min(q))] += 1
print(max(q), z + m)


n = int(int(input()))
m = int(input())
k = m
l = []
for i in range(n):
	x = int(input())
	l.append(x)
a = max(l)
i = 0
while m > 0:
	if i > n - 1:
		i = i % n
	if l[i] == min(l):
		l[i] += 1
		m -= 1
	i += 1
res1 = max(l)
res2 = a + k
print(res1, res2)


def read_int():
	inp = input()
	return int(inp)
n = read_int()
m = read_int()
a = [read_int() for i in range(n)]
s = sum(a)
mx = max(a)
if s + m <= mx * n:
	ans2 = mx
else:
	tp = s + m - mx * n
	if tp % n == 0:
		ans2 = mx + tp // n
	else:
		ans2 = mx + tp // n + 1
print(ans2, mx + m)


n = int(input())
m = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = int(input())
arr_max = max(arr)
people_to_fill = sum((arr_max - i for i in arr))
min_k = arr_max
if people_to_fill < m:
	if (m - people_to_fill) % n == 0:
		min_k += (m - people_to_fill) // n
	else:
		min_k += (m - people_to_fill) // n + 1
max_k = arr_max + m
print(min_k, max_k)


n = int(input())
b = int(input())
lst = []
for i in range(n):
	lst.append(int(input()))
mx = max(lst)
d = sum([mx - i for i in lst])
k = max(b - d, 0)
if k % n != 0:
	d2 = 1
else:
	d2 = 0
print(mx + k // n + d2, mx + b)


import math
n = int(input())
m = int(input())
l = []
mink = 0
maxk = 0
for i in range(n):
	a = int(input())
	l.append(a)
mink += max(math.ceil((sum(l) + m) / n), max(l))
maxk += max(l) + m
print(mink, maxk)


from math import ceil
n = int(input())
m = int(input())
s = 0
mx = -1
for i in range(n):
	k = int(input())
	mx = max(mx, k)
	s += k
print(max(ceil((s + m) / n), mx), mx + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	b = int(input())
	a.append(b)
kmin = a[0]
kmax = a[0]
sum = 0
for i in range(n):
	sum += a[i]
	if kmax < a[i]:
		kmax = a[i]
	if kmin > a[i]:
		kmin = a[i]
if (sum + m) % n == 0:
	out = int((sum + m) / n)
else:
	out = int((sum + m) / n) + 1
if out < kmax:
	kmin = kmax
else:
	kmin = out
print(kmin, kmax + m)


n1 = input()
n = int(n1)
m1 = input()
m = int(m1)
benches = []
i = 0
while i < n:
	benches.append(input())
	i = i + 1
benches = list(map(int, benches))
maxi = int(max(benches)) + m
i = 0
while i < n:
	m = m - int(abs(int(benches[i]) - int(max(benches))))
	i += 1
mini = int(max(benches)) + m // n
if m % n != 0:
	mini += 1
if mini < int(max(benches)):
	mini = int(max(benches))
print(f'{mini} {maxi}')


(n, m) = (int(input()), int(input()))
a = [int(input()) for x in range(n)]
a.sort()
people_left = m - (a[-1] * n - sum(a))
ans = a[-1]
if people_left > 0:
	ans += people_left // n + int(people_left % n != 0)
print(ans, a[-1] + m)


a = int(input())
b = int(input())
i = 0
x = []
while i < a:
	y = int(input())
	x += [y]
	i += 1
k = max(x)
z = 0
i = 0
while i < a:
	z += k - x[i]
	i += 1
if z >= b:
	print(k, k + b)
else:
	c = b - z
	if c % a == 0:
		print(k + c // a, k + b)
	else:
		print(k + c // a + 1, k + b)


n = int(input(''))
m = int(input(''))
t = []
for i in range(n):
	z = int(input(''))
	t.append(z)
t.sort()
w = t[len(t) - 1] + m
for i in range(m):
	t[0] = t[0] + 1
	t.sort()
print(max(t), w)


def solve(n, m, v):
	kmax = max(v) + m
	while m > 0:
		v = sorted(v)
		v[0] += 1
		m -= 1
	return [max(v), kmax]

def main():
	n = int(input())
	m = int(input())
	v = [int(input()) for _ in range(n)]
	print(' '.join([str(x) for x in solve(n, m, v)]))
main()


import math
n = int(input())
m = int(input())
x = m
arr = []
for i in range(n):
	arr.append(int(input()))
maxx = max(arr)
summ = 0
for i in range(n):
	if arr[i] <= maxx:
		if m >= maxx - arr[i]:
			m -= maxx - arr[i]
			arr[i] = maxx
		else:
			arr[i] += m
			m = 0
print(maxx + math.ceil(m / n), maxx + x)


import math
a = int(input())
b = int(input())
s = 0
maxi = 0
for i in range(a):
	c = int(input())
	s += c
	if c > maxi:
		maxi = c
print(max(math.ceil((s + b) / a), maxi), maxi + b, end='')


from math import *
n = int(input())
m = int(input())
a = [int(input()) for x in range(n)]
t = max(a)
print(max((sum(a) + n + m - 1) // n, max(a)), t + m)


n = int(input())
m = int(input())
a = []
s = m
ost = 0
(maxx, minn) = (0, 0)
for i in range(n):
	a.append(int(input()))
	if a[i] > maxx:
		maxx = a[i]
	s += a[i]
if s % n > 0:
	ost = s % n
	minn = 1 + s // n
else:
	minn = s // n
maxx += m
print(max(minn, maxx - m), maxx)


n = int(input())
m = int(input())
a = []
for i in range(0, n):
	a_i = int(input())
	a.append(a_i)

def kMaximo(n, m, a):
	return max(a) + m
u = a
p = m

def kMinimo(n, p, u):
	for i in range(p):
		j = u.index(min(u))
		u[j] = u[j] + 1
		p = p - 1
	if p == 0:
		return max(u)
maximo = kMaximo(n, m, a)
print(kMinimo(n, p, u), maximo)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mm = max(a)
ma = mm + m
c = 0
for i in range(n):
	c += mm - a[i]
if m <= c:
	print(mm, ma)
else:
	q = (m - c) // n
	r = 1 if (m - c) % n > 0 else 0
	print(mm + q + r, ma)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
print(max(max(a), (sum(a) + m + (n - 1)) // n), max(a) + m)


from math import ceil
n = int(input())
m = int(input())
u = m
a = []
for i in range(n):
	a.append(int(input()))
ma = max(a)
s = 0
for i in a:
	s += ma - i
if s >= m:
	print(ma, ma + u)
else:
	m -= s
	print(ma + ceil(m / n), ma + u)


from sys import stdin

def main():
	(n, m, *l) = map(int, stdin.read().splitlines())
	ma = max(l)
	print(max((sum(l) + m + n - 1) // n, ma), ma + m)
main()


import math
n = int(input())
m = int(input())
v = [int(input()) for i in range(n)]
print(max(max(v), math.ceil((sum(v) + m) / n)), max(v) + m)


n = int(input())
m = int(input())
r = []
for i in range(0, n):
	s = int(input())
	r.append(s)
b = max(r) + m
x = m
while x > 0:
	r = sorted(r)
	r[0] = r[0] + 1
	x = x - 1
a = max(r)
print(a, b)


from math import ceil
n = int(input())
m = mm = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mx = max(a)
for item in a:
	m -= mx - item
	if m <= 0:
		break
if m <= 0:
	print(mx, mm + mx)
else:
	print(mx + ceil(m / n), mm + mx)


import os
import sys
n = int(sys.stdin.readline())
m = int(sys.stdin.readline())
a = [int(sys.stdin.readline()) for _ in range(n)]
max_people = 0
total_people = 0
for people in a:
	if people > max_people:
		max_people = people
	total_people += people
res_2 = max_people + m
total_people += m
if max_people * n > total_people:
	res_1 = max_people
else:
	res_1 = total_people // n
	if total_people % n != 0:
		res_1 += 1
sys.stdout.write('{0} {1}'.format(res_1, res_2))


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
ans = [max(a), max(a) + m]
d = m - n * max(a) + sum(a)
if 0 < d:
	ans[0] += (d + n - 1) // n
print(' '.join(map(str, ans)))


from math import ceil
n = int(input())
m = int(input())
arr = list()
for _ in range(int(n)):
	arr.append(int(input()))
arr = sorted(arr)
possible = 0
for a in arr:
	possible = possible + (arr[-1] - a)
if possible >= m:
	print(arr[-1], arr[-1] + m)
else:
	print(int(ceil((m - possible) / len(arr))) + arr[-1], arr[-1] + m)


import sys
s = sys.stdin.readline().strip()
data = []
while s != '':
	data.append(int(s))
	s = sys.stdin.readline().strip()
(n, m) = (data[0], data[1])
setTaked = data[2:]
p = max(setTaked)
max_k = p + m
res = 0
for num in setTaked:
	res += p - num
if res >= m:
	min_k = p
else:
	min_k = p + (m - res) // n
	if (m - res) % n != 0:
		min_k += 1
print('%d %d' % (min_k, max_k))


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
max_num = max(a)
maxa = max_num + m
mina = 0
for i in a:
	if a != max_num:
		k = max_num - i
		m = max(0, m - k)
if m:
	resm = max_num + m // n
	if m % n != 0:
		resm += 1
	mina = resm
else:
	mina = max_num
print(mina, maxa)


import math
n = int(input())
m = int(input())
y = m
a = []
for i in range(n):
	a.append(int(input()))
p = max(a)
q = n * p - sum(a)
if m <= q:
	k1 = p
else:
	m -= q
	r = math.ceil(m / n)
	k1 = p + r
print(k1, p + y)


def main():
	n = int(input())
	m = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	M = max(a)
	MAX = M + m
	for i in range(n):
		while a[i] < M:
			if m == 0:
				break
			a[i] += 1
			m -= 1
	average = m // n
	m = m % n
	if average:
		for i in range(n):
			a[i] += average
	for i in range(n):
		if not m:
			break
		a[i] += 1
		m -= 1
	MIN = max(a)
	print(MIN)
	print(MAX)
main()


all = input().split()[0]
all = int(all)
man = input().split()[0]
man = int(man)
min = 0
max = 0
yz = []
for i in range(all):
	yz.append(int(input().split()[0]))
yz.sort()
max = yz[-1] + man
tmp = 0
if all == 1:
	min = max
	print(min, max)
	exit(0)
while True:
	for i in range(all):
		if (i == all - 1) & (yz[i] == yz[i - 1] - 1):
			yz[i] = yz[i] + 1
			tmp += 1
		if (i == all - 1) & (yz[i] != yz[i - 1] - 1):
			break
		if (yz[i] == yz[i + 1]) & (tmp != man):
			yz[i] = yz[i] + 1
			tmp += 1
		elif (yz[i] < yz[i + 1]) & (tmp != man):
			yz[i] = yz[i] + 1
			tmp += 1
			break
		else:
			break
	if tmp == man:
		break
min = sorted(yz)[-1]
print(min, max)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
k1 = max(a)
kmax = k1 + m
aa = m / n
k2 = sum(a) + m + n - 1
kmin = k2 // n
print(max(kmin, k1), kmax)


from math import ceil
n = int(input())
m = int(input())
bs = []
for _ in range(n):
	bs.append(int(input()))
b = max(bs)
total = sum(bs) + m
maximum = b + m
if total <= b * n:
	minimum = b
else:
	minimum = int(ceil(total / n))
print(minimum, maximum)


n = int(input())
m = int(input())
a = []
for i in range(n):
	t = int(input())
	a.append(t)
ma = max(a)
ma = ma + m
while m > 0:
	mi = min(a)
	a[a.index(mi)] = a[a.index(mi)] + 1
	m = m - 1
mii = max(a)
print(mii, ma)


n = int(input())
m = int(input())
a = list()
for i in range(n):
	t = int(input())
	a.append(t)
a.sort()
sn = sum(a)
sn -= a[n - 1]
q = a[n - 1] * (len(a) - 1) - sn
rem = m - q
mn = 0
mx = 0
if rem >= 0:
	if rem % len(a) == 0:
		mn = a[n - 1] + rem // len(a)
	else:
		mn = a[n - 1] + rem // len(a) + 1
else:
	mn = a[n - 1]
mx = a[n - 1] + m
print(mn, mx)


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
maxk = max(a) + m
for i in range(m):
	p = -1
	for j in range(n):
		if p == -1 or a[j] < a[p]:
			p = j
	if p != -1:
		a[p] += 1
print(max(a), maxk)


import math
n = int(input())
m = int(input())
b = list()
mn = 1000
mx = 0
sm = m
for i in range(n):
	a = int(input())
	sm += a
	if a < mn:
		mn = a
	if a > mx:
		mx = a
	b.append(a)
kmin = max(mx, int(math.ceil(sm / n)))
kmax = mx + m
print(str(kmin) + ' ' + str(kmax))


n = int(input())
m = int(input())
s = ''
for i in range(n):
	s = s + ' ' + input()
l = list(map(int, s.split()))
b = int(max(l))
c = sum(l)
if n == 1:
	k = b + m
elif (c + m - b) / (n - 1) < b:
	k = b
elif (c + m) % n == 0:
	k = (c + m) // n
else:
	k = (c + m) // n + 1
print(k, b + m)


n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
s = sum(a)
mx = max(a)
res_min = max([mx, int((s + m + n - 1) / n)])
res_max = mx + m
print(res_min, res_max)


n = int(input())
m = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
a.sort()
ans2 = a[-1] + m
l = a[-1]
for i in range(len(a) - 1, -1, -1):
	x = min(l - a[i], m)
	m -= x
	a[i] += x
	if m == 0:
		break
if m == 0:
	ans1 = a[-1]
else:
	ans1 = a[-1] + m // n
	if m % n > 0:
		ans1 += 1
print(ans1, ans2)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
res2 = max(a) + m
while m:
	a[a.index(min(a))] += 1
	m -= 1
print(max(a), res2)


n = int(input())
m = int(input())
a = [0] * n
for _ in range(n):
	a[_] = int(input())
minK = arrayMax = max(a)
arrayMin = min(a)
maxK = arrayMax + m
if arrayMax != arrayMin:
	for i in range(n):
		x = arrayMax - a[i]
		a[i] = arrayMax
		m -= x
		if m <= 0:
			break
	arrayMax = max(a)
	arrayMin = min(a)
if arrayMax == arrayMin and m >= 0:
	minK = arrayMax + (m // n if m % n == 0 else m // n + 1)
print(minK, maxK)


from sys import stdin, stdout
import math
n = int(stdin.readline())
m = int(stdin.readline())
cap = [int(line) for line in stdin]
total = m + sum(cap)
best_each = math.ceil(total / n)
(mi, mx) = (best_each, 0)
for c in cap:
	mi = max(mi, c)
	mx = max(mx, c + m)
stdout.write(f'{mi} {mx}')


n = int(input())
m = int(input())
data = []
for x in range(n):
	data.append(int(input()))
Max = max(data) + m
for x in range(m):
	data[data.index(min(data))] += 1
Min = max(data)
print(str(Min) + ' ' + str(Max))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_benches = read_int()
incoming = read_int()
on_benches = []
for _ in range(nb_benches):
	on_benches.append(read_int())
max_ans = max(on_benches) + incoming
for _ in range(incoming):
	on_benches[on_benches.index(min(on_benches))] += 1
min_ans = max(on_benches)
print(min_ans, max_ans)


def inp():
	return list(map(int, input().split()))
(n,) = inp()
(m,) = inp()
a = [int(input()) for i in range(n)]
s = sum(a)
mx = max(a)
mi = max([mx, int((s + m + n - 1) / n)])
mx = mx + m
print(mi, mx)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
res2 = max(a) + m
i = 0
while i < m:
	a[a.index(min(a))] += 1
	i += 1
print(max(a), res2)


import math
n = int(input())
m = int(input())
a = []
for i in range(0, n):
	x = int(input())
	a.append(x)
Max = a[0]
for i in range(0, n):
	Max = max(Max, a[i])
sum = 0
for i in range(0, n):
	sum += Max - a[i]
if sum > m:
	ans1 = Max
else:
	ans1 = math.ceil((m - sum) / n) + Max
ans2 = Max + m
print('%d %d' % (ans1, ans2))


n = int(input())
m = int(input())
l = []
for i in range(n):
	temp = int(input())
	l.append(temp)
l.sort()
tt = l[n - 1]
ttt = m
if l[0] == l[n - 1]:
	if m % n == 0:
		print(m // n + l[0], m + l[0])
	else:
		print(m // n + 1 + l[0], m + l[0])
else:
	ns = 0
	for i in range(n - 1):
		ns += l[n - 1] - l[i]
	if ns >= m:
		print(l[n - 1], tt + ttt)
	else:
		rem = m - ns
		if rem % n == 0:
			print(l[n - 1] + rem // n, l[n - 1] + m)
		else:
			print(l[n - 1] + rem // n + 1, l[n - 1] + m)


def check(x):
	res = 0
	for i in range(n):
		if x < a[i]:
			return 0
		res += x - a[i]
	return res >= m
n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
mx = max(a) + m
l = 0
r = 10 ** 9
while r - l > 1:
	mid = l + r >> 1
	if check(mid):
		r = mid
	else:
		l = mid
print(r, mx)


try:
	n = int(input())
	m = int(input())
	l = []
	for i in range(n):
		x = int(input())
		l.append(x)
	max_k = max(l) + m
	for i in range(m):
		minimum = min(l)
		index = l.index(minimum)
		l[index] += 1
	min_k = max(l)
	print(min_k, max_k)
except EOFError:
	pass


n = int(input())
m = int(input())
a = []
for x in range(n):
	a.append(int(input()))
maximum = max(a) + m
minimum = 0
for i in range(m):
	a[a.index(min(a))] += 1
	m -= 1
print(max(a), maximum)


x = int(input())
p = int(input())
l = []
for i in range(x):
	c = int(input())
	l.append(c)
h = max(l)
max1 = h + p
if h * x - sum(l) >= p:
	min1 = h
elif (p - (h * x - sum(l))) % x == 0:
	min1 = h + (p - (h * x - sum(l))) // x
else:
	min1 = h + (p - (h * x - sum(l))) // x + 1
print(min1, max1)


n = int(input())
p = int(input())
ms = []
for i in range(0, n):
	m = int(input())
	ms.append(m)
mx = max(ms)
m2 = mx + p
diffs = sum([mx - i for i in ms])
if p < diffs:
	m1 = mx
else:
	m1 = p - diffs
	if m1 % n != 0:
		m1 = m1 // n + 1
	else:
		m1 = m1 // n
	m1 += mx
print(m1, m2)


n = int(input())
m = int(input())
u = []
for i in range(n):
	u.append(int(input()))
k = max(u)
a1 = k + m
for i in range(n):
	m -= k - u[i]
if m > 0:
	k += m // n
	if m % n != 0:
		k += 1
print(k, a1)


from sys import stdin

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

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

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
m = iinput()
a = []
for i in range(n):
	a.append(iinput())
mx = max(a) + m
for i in range(m):
	a[a.index(min(a))] += 1
print(max(a), mx)


from math import ceil
num_benches = int(input())
new_people = int(input())
benches = [int(input()) for _ in range(num_benches)]
num_people = sum(benches)
max_benches = max(benches)
total_people = num_people + new_people
if int(ceil(total_people / num_benches)) >= max_benches:
	ans1 = int(ceil(total_people / num_benches))
elif num_benches != 0 and int(ceil((total_people - max_benches) / (num_benches - 1))) >= max_benches:
	ans1 = int(ceil((total_people - max_benches) / (num_benches - 1)))
else:
	ans1 = max_benches
ans2 = max_benches + new_people
print(ans1, ans2)


from math import ceil
n = int(input())
m = int(input())
arr = [int(input()) for _ in range(n)]
count = m
maxx = max(arr)
for i in range(n):
	count -= maxx - arr[i]
if count <= 0:
	print(maxx, maxx + m)
else:
	print(maxx + ceil(count / n), maxx + m)


n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
(l, r, mid, ans) = (max(a), 1000000, max(a), -1)
while l <= r:
	mid = l + r >> 1
	if sum((mid - i for i in a)) >= m:
		(ans, r) = (mid, mid - 1)
	else:
		l = mid + 1
print(ans, max(a) + m)


import math
n = int(input())
m = int(input())
sum = 0
max1 = 0
for i in range(n):
	temp = int(input())
	sum += temp
	max1 = max(max1, temp)
temp = (sum + m) / n
temp = math.ceil(temp)
temp = max(temp, max1)
print(temp, max1 + m)


a = []
n = int(input())
m = int(input())
for i in range(n):
	a.append(int(input()))
kmin = max(a)
for i in range(m):
	a[a.index(min(a))] += 1
print(max(a), kmin + m)


n = int(input())
m = int(input())
(mx, sm) = (0, 0)
for i in range(n):
	x = int(input())
	if x > mx:
		mx = x
	sm += x
(div, mod) = ((sm + m) // n, (sm + m) % n)
if mod > 0:
	div += 1
print(max(div, mx), mx + m)


from copy import deepcopy

def calc_min_max(bench_counts, new_ppl):
	min_bench_counts = deepcopy(bench_counts)
	for i in range(new_ppl):
		min_bench_counts[min_bench_counts.index(min(min_bench_counts))] += 1
	max_bench_counts = deepcopy(bench_counts)
	for i in range(new_ppl):
		max_bench_counts[max_bench_counts.index(max(max_bench_counts))] += 1
	return (max(min_bench_counts), max(max_bench_counts))

def main():
	num_benches = int(input())
	new_ppl = int(input())
	bench_counts = [int(input()) for _ in range(num_benches)]
	print('{} {}'.format(*calc_min_max(bench_counts, new_ppl)))

def test_main():
	assert calc_min_max(list(range(100)), 10000) == (150, 99 + 10000)
main()


n = int(input())
m = int(input())
k = [1] * n
for i in range(n):
	k[i] = int(input())
kmax = m + max(k)
for i in range(m):
	ind = k.index(min(k))
	k[ind] = k[ind] + 1
kmin = max(k)
print(kmin, kmax)


n = int(input())
m = int(input())
a = list()
for i in range(n):
	a.append(int(input()))
a.sort()
m1 = m
kmax = a[n - 1] + m
if n > 1:
	while m1 > 0:
		for i in range(n - 1):
			if m1 > 0:
				k = a[n - 1] - a[i]
				if k > 0:
					if k >= m1:
						m1 = 0
						kmin = a[n - 1]
					a[i] += k
					m1 -= k
				if k == 0:
					a[i] += 1
					m1 -= 1
					kmin = a[i]
		a.sort()
if n == 1:
	kmin = kmax
print(kmin, end=' ')
print(kmax)


import math
n = int(input())
m = int(input())
maxim = 0
arr = []
for _ in range(n):
	el = int(input())
	maxim = max(maxim, el)
	arr.append(el)
maxRes = maxim + m
avail = 0
for i in arr:
	avail += maxim - i
m -= avail
if m < 0:
	rem = 0
else:
	rem = math.ceil(m / n)
minRes = maxim + rem
print(minRes, maxRes)


n = int(input())
m = int(input())
l = []
for _ in range(n):
	x = int(input())
	l.append(x)
mx = max(l) + m
mn = max(l)
for e in l:
	m -= max(l) - e
	if m <= 0:
		print(mn, mx)
		break
else:
	print(mn + m // n + (1 if m % n else 0), mx)


n = int(input())
m = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
arr.sort()
kmax = max(arr) + m
for _ in range(m):
	arr[arr.index(min(arr))] += 1
print(max(arr), kmax)


from math import ceil
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
y = max(a)
s = ceil((sum(a) + m) / n)
print(max(s, y), y + m)


from math import floor
n = int(input())
pessoas = int(input())
soma = 0
m = 0
for _ in range(n):
	aux = int(input())
	m = max(m, aux)
	soma += aux
print('{} {}'.format(max(floor((soma + n + pessoas - 1) / n), m), m + pessoas))


import math
n = int(input())
m = int(input())
y = []
for _ in range(n):
	x = int(input())
	y.append(x)
max_ = max(y)
summ = 0
for i in range(n):
	summ += max_ - y[i]
kmax = max_ + m
kmin = 0
if summ >= m and summ != 0:
	kmin = max_
else:
	kmin = max_ + math.ceil((m - summ) / n)
print(kmin, '', kmax)


n = int(input())
m = int(input())
a = []
cnt = m
for i in range(n):
	a.append(int(input()))
a.sort()
for i in range(n):
	m -= max(a) - a[i]
if m > 0:
	if m % n != 0:
		cur = m // n + 1
	else:
		cur = m // n
	kmin = max(a) + cur
else:
	kmin = max(a)
kmax = max(a) + cnt
print(kmin, kmax)


n = int(input())
m = int(input())
s = [0 for i in range(n)]
for i in range(n):
	s[i] = int(input())
ans2 = max(s) + m
ost = max(s) * n - sum(s)
if ost >= m:
	ans = max(s)
else:
	m -= ost
	ans = max(s) + m // n
	if m % n:
		ans += 1
print(ans, ans2)


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
mz = max(l)
mx = mz + m
s1 = sum(l)
s2 = s1 + m
x = s2 // n
y = s2 % n
if y == 0:
	if mz < x:
		mn = x
	else:
		mn = mz
elif y <= n:
	if mz <= x:
		mn = x + 1
	else:
		mn = mz
else:
	z1 = y // n
	z2 = y % n
	if mz < x:
		mn = x + z1
	else:
		mn = mz
print(mn, mx)


num = int(input())
peo = int(input())
arr = [0] * num
for i in range(num):
	arr[i] = int(input())
maxn = max(arr) + peo
while peo > 0:
	min_i = 0
	min_n = arr[0]
	for i in range(len(arr)):
		if arr[i] < min_n:
			min_n = arr[i]
			min_i = i
	arr[min_i] += 1
	peo -= 1
print(max(arr), maxn)


def main():
	n = int(input())
	m = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	ans2 = max(a) + m

	def min_index():
		temp = 99999
		i = -1
		for j in range(len(a)):
			if a[j] < temp:
				temp = a[j]
				i = j
		return i

	def max_index():
		temp = -1
		i = -1
		for j in range(len(a)):
			if a[j] > temp:
				temp = a[j]
				i = j
		return i
	while True:
		backup = list(a)
		mini = min_index()
		maxi = max_index()
		minn = a[mini]
		maxx = a[maxi]
		if maxx != minn:
			diff = maxx - minn
		else:
			diff = 1
		a[mini] += diff
		m -= diff
		if m <= 0:
			a[mini] += m
			m -= m
		if m == 0:
			print(max(a), ans2)
			break
main()


from sys import stdin, stdout
from collections import defaultdict, Counter, deque
from bisect import bisect, bisect_left
import math
from itertools import permutations
import queue
I = stdin.readline
n = int(I())
m = int(I())
arr = []
for i in range(n):
	a = int(I())
	arr.append(a)
arr.sort()
l = 0
maxi = arr[-1] + m
if n == 1:
	print(maxi, maxi)
else:
	while m != 0:
		diff = min(m, arr[1] - arr[0] + 1)
		arr[0] += diff
		m -= diff
		arr.sort()
	print(arr[-1], maxi)


n = int(input())
m = int(input())
a = []
for i in range(0, n):
	a.append(int(input()))
kma = m + max(a)
if (sum(a) + m) % n == 0:
	kmi = (sum(a) + m) // n
else:
	kmi = (sum(a) + m) // n + 1
if max(a) > kmi:
	kmi = max(a)
print(kmi, kma)


n = int(input())
m = int(input())
a = []
for el in range(n):
	a.append(int(input()))
min_k = (sum(a) + n + m - 1) // n
min_k = max(min_k, max(a))
max_k = max(a) + m
print(min_k, max_k)


n = int(input())
m = int(input())
A = list()
for _ in range(0, n):
	i = int(input())
	A.append(i)
m1 = max(A)
m2 = min(A)
a2 = m + m1
k = m
for i in range(0, n):
	if k <= 0:
		break
	elif A[i] < m1:
		k -= m1 - A[i]
		A[i] += m1 - A[i]
	else:
		continue
a1 = max(A)
if k <= 0:
	pass
	print(a1, a2)
else:
	q = k // n
	r = k % n
	if r == 0:
		a1 += q
	else:
		a1 += q + 1
	print(a1, a2)


n = int(input())
m = int(input())
a = [int(input()) for x in range(n)]
c = m
(kmin, kmax) = (max(a), max(a) + m)
while c > 0:
	imin = a.index(min(a))
	a[imin] += 1
	kmin = max(a[imin], kmin)
	c -= 1
print('{} {}'.format(kmin, kmax))


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
maxs = max(a)
m1 = m
for i in a:
	m -= maxs - i
print(maxs + max(math.ceil(m / n), 0), maxs + m1)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
maxa = max(a) + m
mina = max(max(a), math.ceil((sum(a) + m) / n))
print(str(mina) + ' ' + str(maxa))


n = int(input())
m = int(input())
arr = [int(input()) for i in range(n)]
mx = max(arr) + m
L = max(arr) - 1
R = mx + 1
while R - L > 1:
	med = (L + R) // 2
	done = 0
	bad = False
	for el in arr:
		done += med - el
		if el > med:
			bad = True
	if bad or done < m:
		L = med
	else:
		R = med
print(R, mx)


n = int(input())
m = int(input())
q = []
for i in range(n):
	s = int(input())
	q.append(s)
ans1 = m + max(q)
mini = min(q)
for i in range(m):
	for j in range(n):
		if mini == q[j]:
			q[j] += 1
			break
	mini = min(q)
print(max(q), ans1)


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a.sort()
cnt = sum([a[-1] - a[i] for i in range(n)])
(s1, s2) = (a[-1], a[-1] + m)
if m > cnt:
	m -= cnt
	s1 += m // n
	if m % n > 0:
		s1 += 1
print(str(s1) + ' ' + str(s2))


n = int(input())
m = int(input())
(startPosition, startPosition1) = (list(), list())
for i in range(n):
	a = int(input())
	startPosition.append(a)
	startPosition1.append(a)
for i in range(m):
	startPosition1[startPosition1.index(min(startPosition1))] += 1
startPosition[startPosition.index(max(startPosition))] += m
print(str(max(startPosition1)) + ' ' + str(max(startPosition)))


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
if n == 1:
	print(m + a[0], m + a[0])
else:
	a.sort()
	maxi = a[n - 1] + m
	for j in range(n - 1):
		m = m - (a[n - 1] - a[j])
		if m <= 0:
			break
	if m <= 0:
		mini = a[n - 1]
	else:
		tot = m // n
		if m % n != 0:
			mini = a[n - 1] + tot + 1
		else:
			mini = a[n - 1] + tot
	print(mini, maxi)


(a, b) = (int(input()), int(input()))
s = [int(input()) for i in range(a)]
print(max((sum(s) + a + b - 1) // a, max(s)), max(s) + b)


n = int(input())
m = int(input())
lst = []
for _ in range(n):
	a = int(input())
	lst.append(a)
maximum = max(lst) + m
while m > 0:
	for i in range(n):
		if lst[i] == min(lst) and m > 0:
			lst[i] += 1
			m -= 1
print(f'{max(lst)} {maximum}')


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
ma = max(a)
s = sum(a)
print(max((s + m) // n + ((s + m) % n > 0), ma), ma + m)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
m1 = max(a)
other = m1 + m
for i in range(n):
	if m <= 0:
		break
	m -= m1 - a[i]
if m <= 0:
	print(m1, other)
	exit()
print(m1 + math.ceil(m / n), other)


n = int(input())
m = int(input())
S = 0
A = []
for i in range(n):
	x = int(input())
	S += x
	A.append(x)
print(max((S + m + n - 1) // n, max(A)), max(A) + m)


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	x = int(input())
	a[i] = x
kmax = max(a) + m
a.sort()
for i in range(n):
	if not m:
		break
	x = min(a[n - 1] - a[i], m)
	m -= x
	a[i] += x
q = m // n
r = m % n
for i in range(n):
	a[i] += q
m -= q * n
for i in range(m):
	a[i] += 1
kmin = max(a)
print(kmin, kmax)


(n, m) = (int(input()), int(input()))
a = []
for i in range(n):
	a.append(int(input()))
ma = max(a) + m
m -= max(a) * n - sum(a)
mi = max(a) + max(0, (m + n - 1) // n)
print(mi, ma)


n = input()
n = int(n)
m = input()
m = int(m)
A = []
S = []
for i in range(n):
	o = input()
	o = int(o)
	A.append(o)
u = max(A)
d = u * n
for i in A:
	d = d - i
pie = m - d
e = pie // n
r = pie % n
Kmi = u + e
if r != 0:
	Kmi = Kmi + 1
if pie < 0:
	Kmi = u
Kma = u + m
S.append(Kmi)
S.append(Kma)
for i in S:
	print(i)


num_benches = int(input())
additional_people = int(input())
benches = []
for i in range(num_benches):
	benches.append(int(input()))
benches.sort()
remaining_seats = sum([benches[-1] - i for i in benches])
max_k = benches[-1] + additional_people
min_k = 0
if additional_people - remaining_seats <= 0:
	min_k = benches[-1]
elif (additional_people - remaining_seats) % num_benches == 0:
	min_k = benches[-1] + (additional_people - remaining_seats) // num_benches
else:
	min_k = benches[-1] + (additional_people - remaining_seats) // num_benches + 1
print(min_k, max_k)


n = int(input())
m = int(input())
(lavo4ka, ans) = ([], [])
for i in range(n):
	lavo4ka.append(int(input()))
ans.append(max(lavo4ka) + m)
i = 0
lavo4ka.sort()
while True:
	lavo4ka[0] += 1
	m -= 1
	lavo4ka.sort()
	if m == 0:
		break
ans.append(max(lavo4ka))
ans.sort()
print(*ans)


n = int(input())
m = int(input())
t = []
for k in range(n):
	t.append(int(input()))
v = max(t) + m
u = max(t)
w = 0
for k in t:
	w += u - k
if w < m:
	s = m - w
	h = s // n
	if s % n > 0:
		u += 1
	u += h
print(u, v)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
nn = str(max(a) + m)
s = max(a) - 1
e = max(a) + m + 1
x = 0
while e - s > 1:
	mid = (e + s) // 2
	x = 0
	for i in range(n):
		if a[i] <= mid:
			x += mid - a[i]
	if x < m:
		s = mid
	else:
		e = mid
print(str(e) + ' ' + nn)


from sys import stdin, stdout

def main():
	N = int(input())
	M = int(input())
	A = [int(input()) for _ in [0] * N]
	n = M - (max(A) * N - sum(A))
	if n <= 0:
		min_ = max(A)
	else:
		min_ = max(A) + (n + N - 1) // N
	max_ = max(A) + M
	print(min_, max_)
input = lambda : stdin.readline()
main()


import math
n = int(input())
m = int(input())
ai = [int(input()) for i in range(n)]
if (sum(ai) + m) % n == 0:
	print(max(max(ai), (sum(ai) + m) // n), max(ai) + m)
else:
	print(max(max(ai), (sum(ai) + m) // n + 1), max(ai) + m)


n = int(input())
r = int(input())
s = []
for i in range(n):
	d = int(input())
	s.append(d)
print(max(max(s), -(-(sum(s) + r) // len(s))), max(s) + r)


n = int(input())
m = int(input())
a = list()
for i in range(n):
	a.append(int(input()))
a.sort()
maximum = a[n - 1] + m
for i in range(m):
	a[0] += 1
	a.sort()
minimum = a[n - 1]
print('{0} {1}'.format(minimum, maximum))


import math
N = int(input().strip())
M = int(input().strip())
arr = []
total_seated = 0
for i in range(N):
	seated = int(input().strip())
	total_seated += seated
	arr.append(seated)
lower = max(math.ceil((total_seated + M) / N), max(arr))
higher = max(arr) + M
print(str(lower) + ' ' + str(higher))


n = int(input())
m = int(input())
a = []
_sum = 0
for i in range(n):
	j = int(input())
	a.append(j)
	_sum += j
a = sorted(a)
if n == 1:
	print(m + a[0], m + a[0])
else:
	_max = m + a[-1]
	temp = a[-1] * n
	if temp - _sum >= m:
		print(a[-1], _max)
	else:
		m -= temp - _sum
		_min = a[-1] + int(m / n)
		if m % n != 0:
			_min += 1
		print(_min, _max)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mxa = max(a)
rmx = mxa + m
for x in a:
	m -= mxa - x
rmn = mxa
if m > 0:
	rmn += (m + n - 1) // n
print(rmn, rmx)


n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
max_k = max(a) + m
max_a = max(a)
for ax in a:
	m -= max_a - ax
min_k = max(a)
if m > 0:
	min_k += m // n
	if m % n > 0:
		min_k += 1
print(min_k, max_k)


n = int(input())
m = int(input())
numbers = []
for i in range(n):
	val = int(input())
	numbers.append(val)
max_number = max(numbers)
ans = max_number
suma = 0
for val in numbers:
	suma = suma + max_number - val
while suma < m:
	suma = suma + n
	ans = ans + 1
print(str(ans) + ' ' + str(max_number + m))


def main():
	n = int(input())
	m = int(input())
	t = m
	a = []
	for i in range(n):
		a.append(int(input()))
	a.sort()
	mx = a[-1]
	i = 0
	while m > 0 and i < n:
		m -= mx - a[i]
		i += 1
	if m < 0:
		m = 0
	print((m + n - 1) // n + mx, mx + t)
main()


n = int(input())
m = int(input())
a = [0] * n
s = 0
ma = 0
for i in range(n):
	a[i] = int(input())
	ma = max(a[i], ma)
	s += a[i]
print(max((s + m + n - 1) // n, ma), ma + m)


n = int(input())
m = int(input())
lavs = list()
for i in range(n):
	lavs.append(int(input()))
lavs2 = lavs.copy()
for i in range(m):
	minimum = 10001
	keymin = 0
	for a in range(n):
		if lavs[a] < minimum:
			minimum = lavs[a]
			keymin = a
	lavs[keymin] += 1
print(max(lavs))
for i in range(m):
	maximum = -1
	keymax = 0
	for a in range(n):
		if lavs2[a] > maximum:
			maximum = lavs2[a]
			keymax = a
	lavs2[keymax] += 1
print(max(lavs2))


import math
n = int(input())
m = int(input())
ar = []
flag = 0
s = 0
for _ in range(n):
	ele = int(input())
	ar.append(ele)
	s += ele
	if flag == 0:
		ma = ele
		flag = 1
	elif ma < ele:
		ma = ele
if m < ma * n - s:
	print(ma, ma + m)
else:
	print(int(math.ceil((s + m) / n)), ma + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mx = max(a) + m
if n == 1:
	print(mx, mx)
else:
	while m >= 1:
		ind = a.index(min(a))
		a[ind] += 1
		m -= 1
	print(max(a), mx)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
x = max(a) + m
y = max(max(a), math.ceil((sum(a) + m) / n))
print('{} {}'.format(y, x))


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
M = a[n - 1] + m
temp = n - 2
while temp > -1:
	k = a[n - 1] - a[temp]
	if k:
		if m - k > 0:
			m = m - k
			a[temp] = a[n - 1]
		else:
			a[temp] += m
			m -= m
			break
	temp -= 1
m = int(math.ceil(m / n))
print(a[n - 1] + m, ' ', M)


from math import ceil
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a)
k_max = a[n - 1] + m
if n == 1:
	print(k_max, k_max)
else:
	k_s = a[n - 1] * (n - 1) - sum(a[:n - 1])
	if k_s < m:
		print(ceil((m - k_s) / n) + a[n - 1], k_max)
	else:
		print(a[n - 1], k_max)


from sys import stdin, stdout
from math import ceil

def read_input():
	n = int(stdin.readline())
	m = int(stdin.readline())
	max_on_bench = 0
	sum = 0
	for _ in range(n):
		a = int(stdin.readline())
		if a > max_on_bench:
			max_on_bench = a
		sum += a
	return (n, m, max_on_bench, sum)
(n, m, max_on_bench, sum) = read_input()
largest = max_on_bench + m
smallest = max(ceil((sum + m) / n), max_on_bench)
print('{x} {y}'.format(x=smallest, y=largest))


n = int(input())
m = int(input())
a = []
for i in range(n):
	v = int(input())
	a.append(v)
ma = max(a) + m
l = max(a) - 1
r = ma
while r - l > 1:
	ser = (r + l) // 2
	q = 0
	for i in range(n):
		q += ser - a[i]
	if q >= m:
		r = ser
	else:
		l = ser
print(r, ma)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
maxi = max(a) + m
while m:
	a[a.index(min(a))] += 1
	m -= 1
mini = max(a)
print(mini, maxi)


import sys
import math
n = int(sys.stdin.readline().strip('\n'))
m = int(sys.stdin.readline().strip('\n'))
num = []
for i in range(n):
	num.append(int(sys.stdin.readline().strip('\n')))
num.sort()
max = num[-1] + m
sum = 0
for i in range(n):
	sum += num[-1] - num[i]
if sum > m:
	min = num[-1]
else:
	min = math.ceil((m - sum) / n) + num[-1]
print(min, ' ', max)


n = int(input())
m = int(input())
(l, r1) = ([], 0)
for i in range(n):
	l.append(int(input()))
if (sum(l) + m) % n == 0:
	r1 = (sum(l) + m) // n
else:
	r1 = (sum(l) + m) // n + 1
print(max(r1, max(l)), max(l) + m)


from math import ceil
n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
ma = max(l)
su = 0
for i in l:
	su += ma - i
a = ma + m
if su >= m:
	b = ma
else:
	m -= su
	b = ma + ceil(m / n)
print(b, a)


from math import ceil
n = int(input().strip())
m = int(input().strip())
k = []
for i in range(n):
	ai = int(input().strip())
	k.append(ai)
if n == 1:
	print(m + ai, m + ai)
else:
	mx = max(k)
	l = max(k) + m
	h = max(mx, ceil((sum(k) + m) / n))
	print(h, l)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a += [int(input())]
ma = max(a)
ca = 0
for i in a:
	ca += ma - i
if ca >= m:
	print(ma)
else:
	print(ma + (m - ca + n - 1) // n)
print(m + max(a))


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
s = 0
a = sorted(a)
max = a[-1]
for i in a[:-1]:
	s += max - i
if s >= m:
	min = max
else:
	min = max + (m - s + n - 1) // n
print(min, max + m)


from collections import Counter, defaultdict, deque
import math
read = lambda : list(map(int, input().split()))
getinfo = lambda grid: print(list(map(print, grid)))
p = lambda x: print(x, end=' ')
mod = 10 ** 9 + 7
inf = float('inf')
while True:
	try:
		n = int(input())
		m = int(input())
		a = []
		for i in range(n):
			a.append(int(input()))
		a_max = max(a)
		s = sum(a)
		aver = int(math.ceil((s + m) / n))
		if aver > a_max:
			print(aver, m + a_max)
		else:
			print(a_max, m + a_max)
	except:
		break


import math
n = int(input())
m = int(input())
abc = m
a = []
ans = 0
for i in range(n):
	x = int(input())
	a.append(x)
a.sort()
for j in range(len(a)):
	ans += a[-1] - a[j]
	if j == len(a) - 1:
		if ans >= m:
			ans = max(a)
		else:
			ans = math.ceil((m - ans) / n) + max(a)
print(ans, max(a) + abc)


n = int(input())
m = int(input())
l = [0 for i in range(n)]
for i in range(n):
	l[i] = int(input())
d1 = max(l)
d2 = min(l)
e = sum(l)
r = e + m
if r % n == 0:
	r1 = r // n
else:
	r1 = r // n + 1
print(max(d1, r1), d1 + m)


(n, m) = (int(input()), int(input()))
a = list(map(int, [int(input()) for _ in range(n)]))
summ = sum(a) + m
print(max(max(a), summ // n + (summ % n != 0)), max(a) + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mx = max(a) + m
while m:
	ind = a.index(min(a))
	a[ind] += 1
	m -= 1
mn = max(a)
print(mn, end=' ')
print(mx)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
s = 0
mah = m + a[-1]
for i in range(len(a) - 1):
	s += a[-1] - a[i]
if m > s:
	mi = (m - s) // n
	if (m - s) % n != 0:
		mi += 1
	mi += a[-1]
	print(mi, mah)
else:
	print(a[-1], mah)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
resp2 = m + max(a)
for i in range(m):
	a[a.index(min(a))] += 1
resp1 = max(a)
print(resp1, resp2)


n = int(input())
m = int(input())
a = [None] * n
for i in range(0, n):
	a[i] = int(input())
max1 = max(a)
thesub = max1 * n - sum(a)
if m <= thesub:
	mins = max1
else:
	mins = max1 + (m - thesub + n - 1) // n
print(mins, max1 + m)


n = int(input())
m = int(input())
ns = []
for _ in range(n):
	ns.append(int(input()))
maxx = max(ns)
ans2 = maxx + m
hole = 0
for t in ns:
	hole += maxx - t
if hole >= m:
	ans1 = maxx
else:
	m -= hole
	ans1 = maxx + m // n
	if m % n != 0:
		ans1 += 1
print(ans1, ans2)


import math
n = int(input())
m = int(input())
a = []
max_bench = 0
for i in range(n):
	x = int(input())
	a.append(x)
	max_bench = max(max_bench, x)
s = 0
for x in a:
	s += max_bench - x
if m <= s:
	min_bench = max_bench
else:
	tmp = m - s
	min_bench = max_bench + tmp // n
	if tmp % n != 0:
		min_bench += 1
print(min_bench, max_bench + m)


from math import *
n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
(mx, mx) = (0, 0)
l.sort()
mx = l[-1] + m
su = 0
for i in range(n):
	su += l[-1] - l[i]
if su >= m:
	mn = l[-1]
else:
	mn = l[-1] + int(ceil((m - su) / n))
print(mn, mx)


from sys import stdin, stdout
n = int(stdin.readline())
m = int(stdin.readline())
chal = []
for i in range(n):
	chal.append(int(stdin.readline()))
chal.sort()
cnt = 0
for i in range(n):
	cnt += chal[n - 1] - chal[i]
stdout.write(str((max(0, m - cnt) + n - 1) // n + chal[n - 1]) + ' ' + str(chal[n - 1] + m))


n = int(input())
m = int(input())
t = m
a = []
for i in range(n):
	a.append(int(input()))
b = max(a)
x = 0
for i in a:
	x = x + (b - i)
m = m - x
if m > 0:
	k = 1 if m % n else 0
	m = int(m / n)
	x = b + m + k
	print(x, t + b)
else:
	print(b, t + b)


n = int(input())
m = int(input())
a = []
for x in range(n):
	a.append(int(input()))
max_val = 0
for x in range(n):
	if a[x] > max_val:
		max_val = a[x]
people_left = m
for x in range(n):
	people_left = people_left - (max_val - a[x])
if people_left < 0:
	print(str(max_val) + ' ' + str(max_val + m))
elif people_left % n == 0:
	print(str(max_val + people_left // n) + ' ' + str(max_val + m))
else:
	print(str(1 + max_val + people_left // n) + ' ' + str(max_val + m))


from math import ceil
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
(t, tt) = (max(a), m)
print(max(t, ceil((sum(a) + m) / n)), t + m)


i = input
n = int(i())
m = int(i())
a = [int(i()) for _ in [0] * n]
v = max(a)
u = sum((v - x for x in a))
print(max(0, 0 - -(m - u) // n) + v, m + v)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
s = sum(a)
m1 = max(math.ceil((s + m) / n), max(a))
m2 = max(a) + m
print(int(m1), m2)


n = int(input())
m = int(input())
lt = [0] * n
for i in range(n):
	t = int(input())
	lt[i] = t
mak = max(lt) + m
mik = 0
for i in range(m):
	lt[lt.index(min(lt))] += 1
mik = max(lt)
print(mik, mak)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
m = inp()
a = [0] * n
for i in range(n):
	a[i] = inp()
mini = 1 + (sum(a) + m - 1) // n
mini = max(mini, max(a))
maxi = max(a) + m
print(mini, maxi)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
print(max(math.ceil((sum(a) + m) / n), max(a)), max(a) + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	cur = int(input())
	a.append(cur)
a.sort()
a.reverse()
maxx = max(a) + m

def can_be(a, m, k):
	ost = m
	for i in range(len(a)):
		if a[i] > k:
			return False
		else:
			ost -= k - a[i]
	if ost <= 0:
		return True
	else:
		return False
l = -1
r = maxx
while r > l + 1:
	mid = (l + r) // 2
	if can_be(a, m, mid) == True:
		r = mid
	else:
		l = mid
print(r, maxx)


a = int(input())
b = int(input())
L = []
M = []
c = a
d = b
L.append(b)
while c > 0:
	k = int(input())
	L.append(k)
	M.append(k)
	c = c - 1
l = sum(L)
m = sum(M)
if max(M) >= min(M) + b:
	k2 = max(M)
elif l <= max(M) * a:
	k2 = max(M)
else:
	left = l - max(M) * a
	i = left / a
	if int(i) == i:
		k0 = int(i)
		k2 = max(M) + k0
	else:
		k0 = int(i) + 1
		k2 = max(M) + k0
L2 = max(M)
K3 = L2 + b
print(k2, K3)


from math import ceil
n = int(input())
m = int(input())
l = []
sum = 0
for _ in range(n):
	a = int(input())
	sum += a
	l.append(a)
big = max(l)
print(max(big, ceil((sum + m) / n)), big + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
kmax = max(a) + m
a.sort()
for i in range(m):
	a[0] = a[0] + 1
	a.sort()
print(max(a), kmax)


n = int(input())
m = int(input())
benches = [int(input()) for i in range(n)]

def sum(arr):
	sum_ = 0
	for i in arr:
		sum_ += i
	return sum_

def ceil(a):
	if a - round(a, 0) == 0:
		return int(a)
	else:
		return int(a) + 1
min_k = max(ceil((sum(benches) + m) / n), max(benches))
max_k = max(benches) + m
print(min_k, max_k)


n = int(input())
m = int(input())
benches = list()
for _ in range(n):
	a = int(input())
	benches.append(a)
benches.sort()
g = benches[n - 1]
c = benches.count(g)
C = [0] * n
C[n - 1] = 0
for i in range(n - 1):
	C[i] = g - benches[i]
prefix = [0] * n
prefix[0] = C[0]
for i in range(n):
	prefix[i] = C[i] + prefix[i - 1]
max_k = g + m
if m <= prefix[n - c - 1]:
	min_k = g
else:
	m -= prefix[n - c - 1]
	m -= c
	if m <= 0:
		min_k = g + 1
	elif m <= n - c:
		min_k = g + 1
	else:
		m -= n - c
		q = m // n
		r = m % n
		if r > 0:
			min_k = g + 1 + q + 1
		else:
			min_k = g + 1 + q
print(min_k, max_k)


n = int(input())
m = int(input())
initial = []
for _ in range(n):
	initial.append(int(input()))
M = max(initial)
a = M + m
for i in range(n):
	if m > 0:
		m -= M - initial[i]
		initial[i] = M
	else:
		break
if m <= 0:
	print(M, a)
elif m > 0 and m % len(initial) != 0:
	print(M + m // len(initial) + 1, a)
else:
	print(M + m // len(initial), a)


n = int(input())
k = int(input())
l = []
c = k
for i in range(n):
	l.append(int(input()))
m = max(l)
for i in range(n):
	a = m - l[i]
	if a <= k:
		k = k - a
		l[i] = m
	else:
		l[i] = l[i] + k
		k = 0
while k != 0:
	for i in range(n):
		if k > 0:
			k = k - 1
			l[i] += 1
		else:
			break
mi = max(l)
print(mi, m + c)


n = int(input())
m = int(input())
a = []
for i in range(n):
	ai = int(input())
	a.append(ai)
a.sort()
mx = a[-1] + m
for i in range(m):
	a[0] += 1
	a.sort()
print(max(a), mx)


n = int(input())
m = int(input())
bench = [int(input()) for i in range(n)]
mx = max(bench) + m
for i in range(m):
	bench[bench.index(min(bench))] += 1
print(max(bench), mx)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
maxk = a[-1] + m
cnt = 0
for i in range(n - 1):
	cnt += a[-1] - a[i]
m -= cnt
if m <= 0:
	mink = a[-1]
else:
	mink = a[-1] + m // n
	if m % n != 0:
		mink += 1
print(mink, maxk)


def mi():
	return map(int, input().split())
n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
ma = max(a)
maxk = ma + m
a.sort()
import math
for i in a:
	m -= min(m, ma - i)
if m == 0:
	print(ma, maxk)
else:
	print(ma + math.ceil(m / n), maxk)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	ai = int(input())
	a.append(ai)
tmp_m = m
res2 = m + max(a)
a.sort()
while m > 0:
	m -= 1
	a[0] += 1
	a.sort()
print(max(a), end=' ')
print(res2)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

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

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

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

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
n = ii()
m = ii()
a = [ii() for i in range(n)]
print(max(max(a), math.ceil((sum(a) + m) / n)), max(a) + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
k = 0
q = 0
for i in range(n):
	k += a[i]
	if a[i] > q:
		q = a[i]
k += m
if k % n != 0:
	if q <= k // n + 1:
		print(k // n + 1, m + q)
	else:
		print(q, m + q)
elif q <= k // n:
	print(k // n, m + q)
else:
	print(q, m + q)


n = int(input())
m = int(input())
benchList = []
for i in range(0, n):
	benchList.append(int(input()))
if len(benchList) > 1:
	benchList.sort()
	(benchListAct, minMax) = ([benchList[0] + m] + benchList[1:], 500000000)
	for i in range(0, m + 1):
		minMax = min(minMax, max(benchListAct))
		benchListAct[0] -= 1
		benchListAct[1] += 1
		benchListAct = [benchListAct[0]] + sorted(benchListAct[1:])
	print(minMax, benchList[-1] + m)
else:
	print(benchList[0] + m, benchList[0] + m)


import time
import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
start = time.time()
max_now = max(a)
sum = 0
for i in range(n):
	sum += max_now - a[i]
ans_max = max_now + m
if sum >= m:
	ans_min = max_now
else:
	ans_min = max_now + math.ceil((m - sum) / n)
print(ans_min, ans_max)
finish = time.time()


import math
n = int(input().strip())
m = int(input().strip())
max_p = 0
sum_p = 0
for i in range(n):
	a_i = int(input().strip())
	sum_p += a_i
	max_p = max(max_p, a_i)
print(max(max_p, math.ceil((sum_p + m) / n)), max_p + m)


def readint():
	a = int(input())
	return a
n = readint()
m = readint()
a = []
ma = 0
s = m
for i in range(n):
	j = readint()
	a.append(j)
	ma = max(j, ma)
	s = s + j
j = int(s / n)
if s % n != 0:
	j = j + 1
ans1 = max(j, ma)
ans2 = ma + m
print(str(ans1) + ' ' + str(ans2))


from math import *
n = int(input())
m = int(input())
arr = []
for i in range(n):
	x = int(input())
	arr.append(x)
maxval = max(arr) + m
if max(arr) * n >= sum(arr) + m:
	minval = max(arr)
else:
	minval = ceil((sum(arr) + m - max(arr) * n) / n) + max(arr)
print(minval, maxval)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]

def find_min(a):
	r = float('inf')
	index_r = None
	for (index, elem) in enumerate(a):
		if elem < r:
			index_r = index
			r = elem
	return (index_r, r)
k_max = max(a) + m
for _ in range(m):
	(index, elem) = find_min(a)
	a[index] += 1
k_min = max(a)
print(k_min, k_max)


n = int(input())
m = int(input())
r = []
for _ in range(n):
	r.append(int(input()))
(a, b) = (sum(r), max(r))
c = b * n - a
r1 = 0
r2 = b + m
if m <= c:
	r1 = b
else:
	r1 = b + (m - c + n - 1) // n
print(r1, r2)


from math import ceil
b = int(input())
n = int(input())
nums = []
for i in range(b):
	nums.append(int(input()))
mink = max(ceil((sum(nums) + n) / b), max(nums))
maxk = max(nums) + n
print(str(mink) + ' ' + str(maxk))


n = int(input())
m = int(input())
ss = []
for i in range(0, n):
	ss.append(int(input()))
maxx = max(ss) + m
for i in range(0, m):
	ind = ss.index(min(ss))
	ss[ind] += 1
minn = max(ss)
print(minn, maxx)


def read():
	return int(input())
n = read()
m = read()
sp = []
for i in range(n):
	sp.append(read())
t = sum(sp) + m
if t % n == 0:
	t = t // n
else:
	t = t // n + 1
print(max(t, max(sp)), max(sp) + m)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
s = sum(a)
(mn, mx) = (min(a), max(a))
mx_k = mx + m
m -= mx * n - s
if m > 0:
	mx += m // n
	mx += 1 if m % n else 0
print(mx, mx_k)


from math import ceil
n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a.sort()
kmin = max(a[-1], (sum(a) + m + n - 1) // n)
kmax = a[-1] + m
print(kmin, kmax)


n = int(input())
m = int(input())
a = []
for i in range(0, n):
	a.append(int(input()))
	continue
a.sort()
lack = 0
for i in a:
	lack += a[-1] - i
	continue
if m < lack:
	print(a[-1], a[-1] + m)
else:
	moood = 0
	if (m - lack) % n > 0:
		moood = 1
	print(a[-1] + (m - lack) // n + moood, a[-1] + m)


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
k = max(a)
s = 0
for i in range(n):
	s += abs(k - a[i])
d = m - s
ans1 = 0
ans2 = 0
if d <= 0:
	ans1 = k
else:
	f = d // n
	ans1 += f + k
	if d % n != 0:
		ans1 += 1
print(ans1, k + m)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
m = inp()
a = [0] * n
for i in range(n):
	a[i] = inp()
mini = max(a)
hi = sum(a) + m
lo = max(a)
while hi >= lo:
	mid = (hi + lo) // 2
	temp = m
	for x in a:
		if x <= mid:
			temp -= min(temp, mid - x)
	if temp == 0:
		mini = mid
		hi = mid - 1
	else:
		lo = mid + 1
maxi = max(a) + m
print(mini, maxi)


g = int(input())
m = int(input())
a = []
for i in range(0, g):
	b = int(input())
	a.append(b)
if (sum(a) + m) % g == 0:
	d = int((sum(a) + m) / g)
else:
	d = int((sum(a) + m) / g) + 1
mi = d
if max(a) > d:
	mi = max(a)
mx = max(a) + m
print(mi, mx)


import math
bench = input()
people = input()
peopleOnBench = []
for i in range(int(bench)):
	a = input()
	peopleOnBench.append(int(a))
maximum = max(peopleOnBench) + int(people)
minimum = max(max(peopleOnBench), math.ceil((sum(peopleOnBench) + int(people)) / int(bench)))
print(minimum, maximum)


def print_return(func):

	def wrapper(*args, **kwargs):
		retval = func(*args, **kwargs)
		print(retval)
		return retval
	return wrapper

@print_return
def solve_a(n=None, m=None, people_nrs=None):
	if n is None or m is None or people_nrs is None:
		n = int(input())
		m = int(input())
		people_nrs = [int(input()) for _ in range(n)]
	else:
		people_nrs = [int(x) for x in people_nrs.split('\n')]
	mx = max(people_nrs) + m
	mn = (sum(people_nrs) + m + n - 1) // n
	mn = max(mn, max(people_nrs))
	return '{} {}'.format(mn, mx)

@print_return
def solve_b(n=None, rest=None):
	if n is None:
		n = int(input())
		prices__vitamins = [input().split() for _ in range(n)]
		prices__vitamins = [(int(x[0]), list(x[1])) for x in prices__vitamins]
	else:
		prices__vitamins = [x.split() for x in rest.split('\n')]
		prices__vitamins = [(int(x[0]), list(x[1])) for x in prices__vitamins]
	prices__vitamins = sorted(prices__vitamins, key=lambda x: x[0])
	met_vitamins = []
	for (price, vitamins) in prices__vitamins:
		for vitamin in vitamins:
			if vitamin not in met_vitamins:
				met_vitamins.append(vitamin)
		if len(met_vitamins) > 2:
			break
	if len(met_vitamins) < 3:
		return -1
	min_price = 3 * 10 ** 6
	for (idx, pr_vt) in enumerate(prices__vitamins):
		(price, vitamins) = pr_vt
		curr_set = set(vitamins)
		curr_price = price
		for (idx2, pr_vt) in enumerate(prices__vitamins):
			if idx == idx2:
				continue
			(pr, vts) = pr_vt
			good = False
			for vt in vts:
				if vt not in curr_set:
					curr_set.add(vt)
					good = True
			if good:
				curr_price += pr
		min_price = min(curr_price, min_price)
	return min_price
solve_a()


n = int(input())
m = int(input())
A = [int(input()) for i in range(n)]
A.sort()
ANS2 = max(A) + m
while m != 0:
	x = min(A)
	i = 0
	while i < n and m != 0:
		if A[i] == x:
			A[i] += 1
			i += 1
			m -= 1
		else:
			break
	A.sort()
print(max(A), ANS2)


n = int(input())
m = int(input())
A = []
for _ in range(0, n):
	A.append(int(input()))
print(max(max(A), (sum(A) + m + n - 1) // n), max(A) + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
maxi = a[-1] + m
while m:
	a[a.index(min(a))] += 1
	m -= 1
print(max(a), maxi)


n = int(input())
m = int(input())
A = []
total = None
(curMin, curMax) = (None, None)
for i in range(n):
	A += [int(input())]
	if total == None:
		total = A[-1]
		(curMin, curMax) = (total, total)
	else:
		total += A[-1]
		curMin = min(curMin, A[-1])
		curMax = max(curMax, A[-1])
ansMax = curMax + m
if curMax * n >= m + total:
	ansMin = curMax
else:
	m -= curMax * n - total
	if m % n == 0:
		ansMin = curMax + m // n
	else:
		ansMin = curMax + m // n + 1
print(ansMin, end=' ')
print(ansMax)


f = lambda : int(input())
n = f()
m = f()
a = [f() for i in range(n)]
max_a = max(a) + m
i = 0
for i in range(m):
	a.sort()
	a[0] += 1
print(max(a), max_a)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
k = max(a)
s = sum(a)
x = max((m - (n * k - s) - 1) // n + 1 + k, k)
y = k + m
print(x, y)


n = int(input().rstrip())
m = int(input().rstrip())
L = []
for _ in range(n):
	a = int(input().rstrip())
	L.append(a)
max_a = m + max(L)
k = m
while k:
	L[L.index(min(L))] = min(L) + 1
	k = k - 1
min_a = max(L)
print(str(min_a) + ' ' + str(max_a))


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
need = 0
for i in a:
	need += a[-1] - i
Min = a[-1] if need >= m else a[-1] + math.ceil((m - need) / n)
Max = a[-1] + m
print(Min, Max)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
print(max((sum(a) + n + m - 1) // n, max(a)), max(a) + m)


n = int(input())
m = int(input())
l = [int(input()) for i in range(n)]
print(max((sum(l) + n + m - 1) // n, max(l)), max(l) + m)


a = int(input())
b = int(input())
lst = []
total = 0
for i in range(a):
	tmp = int(input())
	lst.append(tmp)
	total += tmp
x = max(lst)
n = min(lst)
big = x + b
if total <= a * x - b:
	small = x
else:
	tmp = b - (a * x - total)
	small = int(tmp / a) + x
	if tmp % a != 0:
		small += 1
print('%d %d' % (small, big))


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mi = min(a)
cur = m
for i in range(n):
	cur += a[i] - mi
ans = cur // n
if cur % n != 0:
	ans += 1
ma = max(a) + m
print(max(ans + mi, max(a)), ma)


n = int(input())
m = int(input())
maxx = 0
somme = m
for i in range(n):
	r = int(input())
	somme += r
	if maxx < r:
		maxx = r
maxK = maxx + m
c = somme % n
if c == 0:
	s = 0
else:
	s = 1
if somme // n + s < maxx:
	minK = maxx
else:
	minK = somme // n + s
print(int(minK), end=' ')
print(maxK)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
kMin = math.ceil((sum(a) + m) / len(a))
aMax = max(a)
kMax = aMax + m
if kMin > aMax:
	print(kMin, kMax)
else:
	print(aMax, kMax)


n = int(input())
m = int(input())
mas = []
ch = 0
for i in range(n):
	ch = int(input())
	mas.append(ch)
maxim = max(mas)
minim = min(mas)
ch = m
ans = 0
for i in range(m):
	ans = min(mas)
	mas.remove(ans)
	ans += 1
	mas.append(ans)
print(max(mas), maxim + ch)


from math import ceil
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mo = max(a)
te = ceil((sum(a) + m) / n)
if te < mo:
	print('{}'.format(mo), end=' ')
else:
	print('{}'.format(te), end=' ')
print(max(a) + m)


n = int(input())
m = int(input())
A = []
for _ in range(n):
	A.append(int(input()))
l = -1
r = 10 ** 9
while r - l > 1:
	mid = (l + r) // 2
	c = 0
	for i in A:
		if mid >= i:
			c += max(0, mid - i)
		else:
			c = -111
			break
	if c >= m:
		r = mid
	else:
		l = mid
print(l + 1, max(A) + m)


n = int(input())
m = int(input())
cl = []
for i in range(n):
	t = int(input())
	cl.append(t)
mx = max(cl)
vid2 = mx + m
i = 0
while m > 0 and i < n:
	m -= min(m, mx - cl[i])
	i += 1
vid1 = mx
if m > 0:
	e = m // n
	vid1 = e + mx
	if n * e != m:
		vid1 += 1
print('{} {}'.format(vid1, vid2))


n = int(input())
m = int(input())
maux = m
l = []
for i in range(n):
	l += [int(input())]
mi = 0
ma = max(l)
for i in range(n):
	if m <= 0:
		break
	if l[i] < ma:
		aux = ma - l[i]
		if m > aux:
			m -= aux
			l[i] = ma
		else:
			l[i] += m
			m = 0
if m % n == 0:
	mi = max(l) + m / n
else:
	mi = max(l) + m // n + 1
print(int(mi), int(max(l) + maux))


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)
input = sys.stdin.readline

def ceil(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()))

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
m = ii()
a = [0 for i in range(n)]
for i in range(n):
	a[i] = ii()
a.sort()
mx = a[-1] + m
tmp = 0
for i in range(n):
	tmp += a[-1] - a[i]
if m <= tmp:
	mn = a[-1]
else:
	q = (m - tmp) // n
	r = (m - tmp) % n
	if r:
		mn = a[-1] + q + 1
	else:
		mn = a[-1] + q
print(mn, mx, sep=' ')


import math
n = int(input())
m = int(input())
mx = 0
s = m
for i in range(n):
	x = int(input())
	mx = max(x, mx)
	s += x
a1 = max(mx, math.ceil(s / n))
a2 = mx + m
print(a1, end=' ')
print(a2)


n = int(input())
m = int(input())
arr = [int(input()) for x in range(n)]
mx = max(arr) + m
rem = max(arr) * n - sum(arr)
if rem >= m:
	print(max(arr), mx)
else:
	rem = m - rem
	print(max(arr) + (rem + n - 1) // n, mx)


n = int(input())
m = int(input())
a = []
for i in range(0, n):
	a.append(int(input()))
tempMax = max(a)
maxx = tempMax + m
tempSum = 0
for i in a:
	tempSum += tempMax - i
if tempSum >= m:
	minn = tempMax
else:
	minn = tempMax + (m - tempSum) // n + (0 if (m - tempSum) % n == 0 else 1)
print(minn, maxx)


kol_vo = int(input())
was = int(input())
maximum = 0
g = 0
f = []
for _ in range(kol_vo):
	h = int(input())
	if h > maximum:
		maximum = h
	g += h
	f += [h]
h = []
if (was + g) % kol_vo == 0:
	o = (was + g) // kol_vo
else:
	o = (was + g) // kol_vo + 1
if max(f) > o:
	h.append(max(f))
else:
	h.append(o)
h.append(maximum + was)
print(*h)


n = int(input())
p = int(input())
t = 0
l = []
for x in range(n):
	k = int(input())
	l.append(k)
for item in l:
	t += max(l) - item
if t >= p:
	print(max(l), max(l) + p)
else:
	tom = p - t
	if tom / n == tom // n:
		print(max(l) + int(tom / n), max(l) + p)
	else:
		print(max(l) + int(tom // n + 1), max(l) + p)


import math
n = int(input())
m = int(input())
total = m
maxN = 0
for i in range(n):
	a = int(input())
	total += a
	maxN = max(maxN, a)
print('%d %d' % (max(maxN, math.ceil(total / n)), math.ceil(maxN + m)))


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]
n = int(ii())
m = int(ii())
data = [int(ii()) for i in range(n)]
h = max(data)
for i in range(n):
	data[i] = h - data[i]
if sum(data) >= m:
	ans1 = h
else:
	ans1 = h + (m - sum(data) + n - 1) // n
print(ans1, m + h)


n = int(input())
m = int(input())
l = sorted([int(input()) for _ in range(n)])
max_val = l[-1] + m
min_val = l[-1]
c = 0
for i in range(n):
	c += min_val - l[i]
if c < m:
	min_val += (m - c) // n if (m - c) % n == 0 else (m - c) // n + 1
print(min_val, max_val)


import math
n = int(input())
m = int(input())
ns = sorted([int(input()) for _ in range(n)])
mx = ns[-1]
b = ns[-1] + m
s = sum(ns)
t = mx * n
m -= t - s
if m > 0:
	a = math.ceil(m / n) + mx
else:
	a = mx
print(a, b)


n = int(input())
m = int(input())
a = []
sum1 = int(0)
for i in range(0, n):
	a.append(int(input()))
	sum1 = sum1 + a[i]
a.sort()
max1 = int(a[n - 1] + m)
min1 = int(a[n - 1])
if a[n - 1] * n - sum1 < m:
	m = m - (a[n - 1] * n - sum1)
	min1 = min1 + int(m / n)
	if m % n != 0:
		min1 = min1 + 1
print(min1, end=' ')
print(max1)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
(m,) = I()
a = [0] * n
for i in range(n):
	(a[i],) = I()
mx = max(a)
ans = mx + m
a.sort()
for i in range(n):
	temp = min(m, mx - a[i])
	m -= temp
	a[i] += temp
from math import ceil
print(mx + ceil(m / n), ans)


n = int(input())
p = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
import math
print(max(max(a), math.ceil((sum(a) + p) / n)), max(a) + p)


import math
n = int(input())
k = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
mi = math.ceil((sum(arr) + k) / n)
ma = max(arr)
print(mi if mi > ma else ma, ma + k)


import math
n = int(input())
m = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
max1 = max(arr) + m
if m > n * max(arr) - sum(arr):
	m -= n * max(arr) - sum(arr)
	min1 = max(arr) + math.ceil(m / n)
else:
	min1 = max(arr)
print(min1, ' ', max1)


import math
from sys import stdin
benches = int(input())
people = int(input())
pinb = [0] * benches
i = 0
for line in stdin:
	pinb[i] += int(line)
	i += 1
maxp = max(pinb)
max_ans = maxp + people
min_ans = max(pinb)
for bench in pinb:
	if bench < maxp:
		dif = maxp - bench
		people -= dif
	if people <= 0:
		break
if people > 0:
	min_ans += math.ceil(people / benches)
print(min_ans, max_ans)


def increment_min(lst):
	lst[lst.index(min(lst))] += 1
benches = int(input())
people = int(input())
sitting = []
for bench in range(benches):
	sitting.append(int(input()))
min_case = sitting.copy()
[increment_min(min_case) for man in range(people)]
print(max(min_case))
print(max(sitting) + people)


a = int(input())
b = int(input())
c = []
for i in range(a):
	d = int(input())
	c.append(d)
print(max(max(c), -(-(sum(c) + b) // len(c))), max(c) + b)


def needed(mi, a):
	ans = 0
	for i in range(len(a)):
		ans += max(0, mi - a[i])
	return ans
n = int(input())
m = int(input())
a = []
maximo = 0
for i in range(n):
	x = int(input())
	a.append(x)
	maximo = max(maximo, x)
maximo += m
lo = 0
hi = maximo
while lo < hi:
	mi = lo + (hi - lo + 1 >> 1)
	if needed(mi, a) <= m:
		lo = mi
	else:
		hi = mi - 1
minimo = lo
if needed(lo, a) < m:
	minimo += 1
minimo = max(minimo, max(a))
print(minimo, maximo)


import math
n = int(input().strip())
m = int(input().strip())
init_people = []
for _ in range(n):
	init_people.append(int(input().strip()))
init_people.sort()
min_k = init_people[0]
i = 1
m_min = m
while m_min > 0:
	if i == n:
		min_k += math.ceil(m_min / n)
		break
	diff = init_people[i] - init_people[i - 1]
	sub = min(diff, math.ceil(m_min / i))
	m_min -= i * sub
	min_k += sub
	i += 1
if n == 1:
	min_k = init_people[0] + m
print(max(min_k, max(init_people)), init_people[-1] + m)


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a = sorted(a)
max_i = max(a) + m
for i in range(m):
	a[0] += 1
	a = sorted(a)
min_i = max(a)
print(min_i, max_i)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, **kwargs, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
N = int(input())
M = int(input())
za = []
for i in range(N):
	za.append(int(input()))
t = sum(za)
x = (t + M - 1) // N + 1
print(max(x, max(za)), max(za) + M)


import heapq
N = int(input())
M = int(input())
src = [int(input()) for i in range(N)]
mx = max(src) + M
hq = src[:]
heapq.heapify(hq)
for i in range(M):
	m = heapq.heappop(hq)
	heapq.heappush(hq, m + 1)
while hq:
	mn = heapq.heappop(hq)
print(mn, mx)


n = int(input().strip())
m = int(input().strip())
max = 0
total = 0
for i in range(n):
	a = int(input().strip())
	if a > max:
		max = a
	total += a
if total + m <= n * max:
	print(max)
else:
	print((total + m - 1) // n + 1)
print(m + max)


import math
n = int(input())
m = int(input())
a = []
suma = 0
for i in range(n):
	a.append(int(input()))
	suma += a[-1]
x = max(a)
moding = n * x - suma
maxi = x + m
mini = x
if m - moding > 0:
	if (m - moding) / n - (m - moding) // n < 0.001:
		mini += (m - moding) // n
	else:
		mini += math.ceil((m - moding) / n)
print(mini, maxi)


import math
n = int(input())
m = int(input())
max_element = 0
sum_of_element = 0
for i in range(n):
	a = int(input())
	if a > max_element:
		max_element = a
	sum_of_element += a
print(max(max_element, math.ceil((m + sum_of_element) * 1.0 / n)), end=' ')
print(m + max_element)


import math
n = int(input())
m = int(input())
R = []
for i in range(n):
	R.append(int(input()))
p = math.ceil((sum(R) + m) / n)
if p < max(R):
	p = max(R)
print(p, max(R) + m)


from math import ceil
n = int(input())
m = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
l.sort()
mk = max(l) + m
for i in range(n):
	if m == 0:
		break
	if m >= l[-1] - l[i]:
		m = m - (l[-1] - l[i])
		l[i] = l[-1]
	else:
		l[i] += m
		m = 0
l = list(set(l))
if m != 0:
	sk = min(l) + ceil(m / n)
else:
	sk = max(l)
print(sk, mk)


n = int(input())
m = int(input())
a = [0] * n
l = [0] * n
for i in range(n):
	a[i] = l[i] = int(input())
r = m
while m != 0:
	l[l.index(min(l))] += 1
	m -= 1
print(max(l), end=' ')
print(r + max(a))


n = int(input())
m = int(input())
a = list()
for i in range(n):
	A = int(input())
	a.append(A)
maxofa = max(a)
mx = m + maxofa
(imn, ind) = (0, a[n - 1])
for i in range(m):
	ind = 10000
	for i in range(n):
		if a[i] <= ind:
			ind = a[i]
			imn = i
	a[imn] += 1
mn = max(a)
print(mn, mx)


n = int(input())
m = int(input())
myMax = 0
counter = 0
for i in range(0, n):
	newBench = int(input())
	if i == 0:
		myMax = newBench
	if myMax >= newBench:
		counter += myMax - newBench
	else:
		counter += i * (newBench - myMax)
		myMax = newBench
if counter >= m:
	print(myMax, myMax + m)
else:
	minMax = (m - counter) // n + myMax
	if (m - counter) % n != 0:
		minMax += 1
	print(minMax, myMax + m)


n = int(input())
m = int(input())
li = [int(input()) for i in range(n)]
max_k = max(li) + m
if max(li) * n > sum(li) + m:
	min_k = max(li)
elif (m + sum(li) - max(li) * n) % n == 0:
	min_k = (m + sum(li) - max(li) * n) // n + max(li)
else:
	min_k = (m + sum(li) - max(li) * n) // n + 1 + max(li)
print(min_k, max_k)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

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

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 sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
m = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l.sort()
a = l[-1] + m
b = l[-1] * n - sum(l)
if b >= m:
	print(l[-1], a)
else:
	m -= b
	c = l[-1]
	if m % n == 0:
		print(c + m // n, a)
	else:
		print(c + 1 + m // n, a)


n = int(input())
k = int(input())
max_tmp = 0
sum_tmp = 0
min_k = 0
for i in range(n):
	tmp = int(input())
	max_tmp = max(max_tmp, tmp)
	sum_tmp += tmp
if sum_tmp + k <= max_tmp * n:
	min_k = max_tmp
else:
	min_k = max_tmp + (sum_tmp + k - max_tmp * n + n - 1) // n
print(min_k, max_tmp + k)


n = int(input())
m = int(input())
a = [int(input()) for x in range(n)]
mx = max(a)
k = 1
sm = len(a) * max(a) - sum(a)
m1 = m
if m < sm:
	m1 = 0
else:
	m1 = m - sm
if m1 % n == 0:
	k = 0
print(mx + m1 // n + k, mx + m, end=' ')


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
ma = max(l)
mx = ma + m
l.sort()
for i in range(n):
	m -= ma - l[i]
if m <= 0:
	mi = ma
else:
	mi = ma + m // n
	if m % n != 0:
		mi += 1
print(mi, mx)


import sys
import math
input = sys.stdin.readline
n = int(input())
m = int(input())
a_list = []
a_max = 0
for _ in range(n):
	a = int(input())
	if a_max < a:
		a_max = a
	a_list.append(a)
tmp = 0
for a in a_list:
	tmp += a_max - a
if tmp >= m:
	a_min = a_max
else:
	a_min = a_max + math.ceil((m - tmp) / n)
print(a_min, a_max + m)


n = int(input())
m = int(input())
max_k = 0
sum = 0
min_k = 0
for i in range(n):
	a = int(input())
	sum += a
	min_k = max(min_k, a)
max_sum = min_k * n
max_k = min_k + m
if max_sum < sum + m:
	m -= max_sum - sum
	min_k += m // n + (1 if m % n != 0 else 0)
print(min_k, max_k)


import math
n = int(input())
m = int(input())
mo = m
s = []
for o in range(n):
	s.append(int(input()))
mi = min(s)
ma = max(s)
for i in range(len(s)):
	m -= ma - s[i]
	s[i] = ma
if m <= 0:
	print(ma, ma + mo)
else:
	print(ma + math.ceil(m / n), ma + mo)


def finding_k(m, n, bench):
	bench = sorted(bench)
	biggest = bench[-1]
	maxi = biggest + n
	for x in range(m):
		if n > 0:
			diff = biggest - bench[x]
			if diff > n:
				bench[x] += n
				n = 0
			else:
				bench[x] += diff
				n -= diff
		else:
			break
	leftover = n // m
	if n % m != 0:
		return (max(bench) + leftover + 1, maxi)
	return (max(bench) + leftover, maxi)
m = int(input())
n = int(input())
bench = []
for x in range(m):
	bench.append(int(input()))
(ans1, ans2) = finding_k(m, n, bench)
print(ans1, ans2)


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

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

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 SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

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

def li():
	return list(map(int, input().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')

def power_set(L):
	cardinality = len(L)
	n = 2 ** cardinality
	powerset = []
	for i in range(n):
		a = bin(i)[2:]
		subset = []
		for j in range(len(a)):
			if a[-j - 1] == '1':
				subset.append(L[j])
		powerset.append(subset)
	powerset_orderred = []
	for k in range(cardinality + 1):
		for w in powerset:
			if len(w) == k:
				powerset_orderred.append(w)
	return powerset_orderred

def fastPlrintNextLines(a):
	print('\n'.join(map(str, a)))

def sortByFirstAndSecond(A):
	A = sorted(A, key=lambda x: x[0])
	A = sorted(A, key=lambda x: x[1])
	return list(A)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = 1
for _ in range(t):
	n = ii()
	m = ii()
	l = []
	for i in range(n):
		l.append(ii())
	mxk = max(l) + m
	cur = 0
	mx = max(l)
	for i in range(n):
		cur += mx - l[i]
	mnk = max(l) + max(0, divideCeil(m - cur, n))
	print(mnk, mxk)


n = int(input())
m = int(input())
nums = [int(input()) for x in range(n)]
(l, r) = (min(nums), max(nums) + m)
while l < r:
	mid = (l + r) // 2
	if sum((max(0, mid - x) for x in nums)) < m:
		l = mid + 1
	else:
		r = mid
print(max(l, *nums), end=' ')
print(max(nums) + m)


import math
n = int(input())
m = int(input())
lst = []
for j in range(n):
	i1 = int(input())
	lst.append(i1)
M = max(lst)
m2 = M + m
s = 0
for j in range(n):
	s += M - lst[j]
if m <= s:
	m1 = M
else:
	m1 = math.ceil((m - s) / n) + M
print(m1, m2, end=' ')


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
maxi = max(l)
l.sort()
tempm = m
for i in range(n):
	if m <= 0:
		break
	if m >= l[n - 1] - l[i]:
		m -= l[n - 1] - l[i]
		l[i] = l[n - 1]
	else:
		m = 0
		l[i] += m
if m > 0:
	residue = 1 if m % n != 0 else 0
	for i in range(n):
		l[i] += m // n
		if i == n - 1 and residue != 0:
			l[i] += 1
maxi2 = max(l)
minans = maxi2
maxans = maxi + tempm
print(minans, end=' ')
print(maxans)


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
MAX = max(a) + m
MIN = math.ceil((sum(a) + m) / n)
if MIN < max(a):
	MIN = max(a)
print(MIN, MAX)


n = int(input())
k = int(input())
a = []
for i in range(n):
	a += [int(input())]
mx = max(a)
mn = min(a)
if n == 1:
	print(mx + k, mx + k)
else:
	r2 = mx + k
	sm = 0
	for i in range(n):
		sm += mx - a[i]
	if sm >= k:
		r1 = mx
	else:
		k -= sm
		res = k // n
		if k % n == 0:
			r1 = mx + res
		else:
			r1 = mx + res + 1
	print(r1, r2)


import sys
import math
import bisect

def solve(A, m):
	n = len(A)
	max_val = max(A) + m
	delta = max(A) * n - sum(A)
	if delta >= m:
		return (max(A), max_val)
	m -= delta
	min_val = max(A) + (m + n - 1) // n
	return (min_val, max_val)

def main():
	n = int(input())
	m = int(input())
	A = []
	for i in range(n):
		A.append(int(input()))
	ans = solve(A, m)
	print('%d %d' % (ans[0], ans[1]))
main()


import math
n = int(input())
m = int(input())
ma = 0
t = m
for x in range(n):
	z = int(input())
	t += z
	ma = max(ma, z)
print(max(ma, math.ceil(t / n)), ' ', ma + m)


import math
b = int(input())
n = int(input())
a = []
largest = -1
for i in range(b):
	a.append(int(input()))
	if a[i] > largest:
		largest = a[i]
t = sum(a) + n
smallest = math.ceil(t / b)
smallest = max(smallest, largest)
print(str(smallest) + ' ' + str(largest + n))


import math
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
x = max(a)
y = min(a)
op = (sum(a) + m) / n
if op != int(op):
	op = op + 1
print(max(x, int(op)), x + m)


def main():
	(n, m) = (int(input()), int(input()))
	a = [int(input()) for i in range(n)]
	(max_a, cnt) = (max(a), 0)
	max_ans = max_a + m
	for i in a:
		cnt += max_a - i
	m -= cnt
	if m <= 0:
		min_ans = max_a
	else:
		min_ans = max_a + (m + n - 1) // n
	print(min_ans, max_ans)
main()


import sys
import math
lines = []
for line in sys.stdin:
	lines.append(int(line))
income = lines[1]
peoples = lines[2:]
top = max(peoples)
flop = max(top, math.ceil((sum(peoples) + income) / lines[0]))
print('{} {}'.format(flop, top + income))


USE_STDIO = False
if not USE_STDIO:
	try:
		import mypc
	except:
		pass

def main():
	(n,) = map(int, input().split(' '))
	(m,) = map(int, input().split(' '))
	(total, M) = (0, 0)
	a = [0] * n
	for i in range(n):
		(a[i],) = map(int, input().split(' '))
		total += a[i]
		M = max(M, a[i])
	maxk = M + m
	mink = M
	for x in a:
		m -= M - x
	if m > 0:
		mink += (m + n - 1) // n
	print(mink, maxk)
main()


n = int(input())
m = int(input())
li = []
for j in range(0, n):
	r = int(input())
	li.append(r)
ma = max(li) + m
for j in range(0, m):
	li[li.index(min(li))] = min(li) + 1
print(max(li), end=' ')
print(ma)


n = int(input())
k = int(input())
a = [int(input()) for i in range(n)]
b = a[:]
for i in range(k):
	a[a.index(min(a))] += 1
print(max(a), max(b) + k)


from math import ceil
n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
mini = max(ceil((sum(arr) + m) / n), max(arr))
maxi = max(arr) + m
print(mini, maxi)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
from collections import *
ORDA = 97

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

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

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

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

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

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def function(arr, size, dp):
	if size == 1 or size == 0:
		return 1
	key = ''.join(map(str, arr[:size]))
	if dp[key]:
		return dp[key]
	output = function(arr, size - 1, dp)
	key = ''.join(map(str, arr[:size - 1]))
	dp[key] = output
	if arr[size - 2] * 10 + arr[size - 1] <= 26:
		output += function(arr, size - 2, dp)
		key = ''.join(map(str, arr[:size - 2]))
		dp[key] = output
	return output

def main():
	n = ii()
	m = ii()
	arr = []
	for _ in range(n):
		arr.append(ii())
	mx = max(arr)
	s = 0
	for i in range(n):
		arr[i] = mx - arr[i]
		s += arr[i]
	if m <= s:
		print(mx, mx + m)
	else:
		s = m - s
		if s % n == 0:
			print(mx + s // n, mx + m)
		else:
			print(mx + s // n + 1, mx + m)
main()


n = int(input())
m = int(input())
a = []
b = m
for i in range(n):
	a.append(int(input()))
a.sort()
maxa = max(a)
for i in range(n):
	if a[i] < maxa:
		if m >= maxa - a[i]:
			m = m - (maxa - a[i])
			a[i] += maxa - a[i]
		else:
			a[i] += m
			m = 0
	if m == 0:
		break
temp = max(a)
temp += m // n
if m % n != 0:
	temp += 1
print(temp, maxa + b)


n = int(input())
m = int(input())
aa = []
for i in range(n):
	aa += [int(input())]
maxAns = max(aa) + m
rest = max(aa) * n - sum(aa)
if m <= rest:
	minAns = max(aa)
else:
	m -= rest
	minAns = max(aa) + (m + n - 1) // n
print(minAns, maxAns)


import math
n = int(input())
k = int(input())
arr = [int(input()) for _ in range(n)]
x = math.ceil(k / n)
arr2 = [max(arr) - x for x in arr]
if sum(arr2) >= k:
	print(max(arr), end=' ')
else:
	t = k - sum(arr2)
	x2 = math.ceil(t / n)
	print(max(arr) + x2, end=' ')
print(max(arr) + k)


numBench = int(input())
m = int(input())
benches = []
for x in range(0, numBench):
	benches.append(int(input()))
outmax = max(benches) + m
for x in range(m, 0, -1):
	benches[benches.index(min(benches))] += 1
outmin = max(benches)
print(str(outmin) + ' ' + str(outmax))


import math
n = int(input())
m = int(input())
list = []
for i in range(n):
	list.append(int(input()))
max_k = max(list) + m
list.sort()
if min(list) + m <= max(list):
	min_k = max(list)
	print(min_k, max_k)
	exit()
i = 0
while m > 0 and i < n - 1:
	p = max(list) - list[i]
	m -= p
	list[i] = max(list)
	i += 1
if m > 0:
	min_k = int(math.ceil(m / n)) + max(list)
else:
	min_k = max(list)
print(min_k, max_k)


import math
n = int(input())
m = int(input())
x = [int(input()) for v in range(n)]
x_max = max(x)
x_sum = sum(x)
xx_min = math.ceil((x_sum + m) / n)
xx_min = max([xx_min, x_max])
xx_max = x_max + m
print(xx_min, xx_max)


n = int(input())
m = int(input())
A = [int(input()) for _ in range(n)]
x = max(A)
print(max(x, (sum(A) + n + m - 1) // n), x + m)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
_max = max(a) + m
while m > 0:
	a[a.index(min(a))] += 1
	m -= 1
_min = max(a)
print(_min, _max)


import math
n = int(input())
m = int(input())
lavki = []
for i in range(n):
	lavki.append(int(input()))
lavki.sort()
if math.ceil((sum(lavki) + m) / len(lavki)) > lavki[-1]:
	c = math.ceil((sum(lavki) + m) / len(lavki))
else:
	c = lavki[-1]
print(c, lavki[-1] + m)


n = int(input())
m = int(input())
arr = []
qwe = []
for i in range(n):
	q = int(input())
	arr.append(q)
	qwe.append(q)
cnt = m
while cnt != 0:
	mini = min(qwe)
	i = qwe.index(mini)
	qwe[i] += 1
	cnt -= 1
a = max(qwe)
b = max(arr) + m
print(str(a) + ' ' + str(b))


import math
num_benches = int(input())
new_ppl = int(input())
xs = [None] * num_benches
for i in range(num_benches):
	xs[i] = int(input())
max_ppl = max(xs)
capacity = sum([max_ppl - x for x in xs])
min_k = None
max_k = max_ppl + new_ppl
if new_ppl <= capacity:
	min_k = max_ppl
else:
	min_k = max_ppl + math.ceil((new_ppl - capacity) / num_benches)
print(min_k, max_k)


def main():
	n = int(input())
	m = int(input())
	arr = []
	for i in range(n):
		arr.append(int(input()))
	arr.sort()
	mx = arr[-1]
	for i in range(m):
		arr[0] += 1
		idx = 0
		while idx + 1 < n and arr[idx] > arr[idx + 1]:
			(arr[idx], arr[idx + 1]) = (arr[idx + 1], arr[idx])
			idx += 1
	print(arr[-1], mx + m)
main()


import math
n = int(input())
m = int(input())
mi = -1
s = m
for j in range(n):
	l = int(input())
	s = s + l
	mi = max(mi, l)
mil = math.ceil(s / n)
if mil < mi:
	mil = mi
mak = mi + m
print(mil, mak)


import heapq

def benches(l, m):
	ln = list(l)
	heapq.heapify(ln)
	i = 0
	while i < m:
		tmp = heapq.heappop(ln)
		tmp += 1
		heapq.heappush(ln, tmp)
		i += 1
	print(max(ln), max(l) + m)
n = int(input())
m = int(input())
lt = []
for _ in range(n):
	lt.append(int(input()))
benches(lt, m)


n = int(input())
m = int(input())
arr = []
for i in range(n):
	a = int(input())
	arr.append(a)
arr = sorted(arr)
ans2 = arr[n - 1] + m
s = sum(arr[:n - 1])
t = arr[n - 1] * (n - 1) - s
if m >= t:
	m = m - t
	if m % n == 0:
		ans1 = arr[n - 1] + int(m / n)
	else:
		ans1 = arr[n - 1] + int(m / n) + 1
else:
	ans1 = arr[n - 1]
print(ans1, ans2)


import sys
import math
n = int(input())
m = int(input())
comba = []
for _ in range(n):
	x = int(input())
	comba.append(x)
comba = sorted(comba, reverse=True)
kaa = m
maxa = comba[0]
for i in range(n):
	if comba[i] < maxa:
		kaa -= maxa - comba[i]
		comba[i] = maxa
		if kaa < 0:
			kaa = 0
print(comba[0] + math.ceil(kaa / n), maxa + m)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

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

def instr():
	s = input()
	return list(s[:len(s)])

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

def b_seach(n, d):
	l = 0
	r = n
	while l <= r:
		mid = l + (r - l) // 2
		tot = mid + int(ceil(d / (mid + 1)))
		if tot <= n:
			return mid
		l = mid + 1
	return -1

def main():
	n = inp()
	m = inp()
	a = []
	for _ in range(n):
		a.append(inp())
	tot = sum(a) + m
	target = tot // n
	baki = tot - target * n
	if baki > 0:
		target += 1
	maxi = max(a) + m
	print(max(target, max(a)), maxi)
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))

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


def indmin(m):
	a = min(m)
	for i in range(len(m)):
		if m[i] == a:
			return i
a = int(input())
b = int(input())
m = []
ind = 0
d = 0
for i in range(a):
	m.append(int(input()))
c = list(m)
for i in range(b):
	c[indmin(c)] += 1
d = max(m) + b
print(max(c), d)


import math
n = int(input())
people = int(input())
biggest = 0
newpeople = 0
for i in range(n):
	new = int(input())
	newpeople += new
	if new > biggest:
		biggest = new
min = math.ceil((newpeople + people) / n)
max = biggest + people
if biggest > min:
	min = biggest
print(str(min) + ' ' + str(max))


(n, m) = (int(input()), int(input()))
ar = [int(input()) for x in range(n)]
mx = max(ar) + m
for i in range(m):
	ar[ar.index(min(ar))] += 1
print(max(ar), mx)


import math

def main():
	n = int(input())
	m = int(input())
	a = [0] * n
	mx = 0
	for i in range(n):
		a[i] = int(input())
		if a[i] > mx:
			mx = a[i]
	reserve = sum(map(lambda item: mx - item, a))
	k_max = mx + m
	added = m - reserve
	if added > 0:
		added /= n
	elif added < 0:
		added = 0
	k_min = mx + math.ceil(added)
	print(k_min, k_max)
main()


n = int(input())
m = int(input())
a = []
for x in range(n):
	a.append(int(input()))
a = sorted(a)
mayor = a[-1] + m
t = a
i = 0
for x in range(1, m + 1):
	t[0] = t[0] + 1
	t = sorted(t)
menor = t[-1]
print(menor, mayor)


n = int(input())
m = int(input())
arr = []
max = 0
for _ in range(n):
	x = int(input())
	if x > max:
		max = x
	arr.append(x)
kmax = max + m
arr = sorted(arr)
used = False
while m > 0:
	for i in range(1, len(arr)):
		while arr[i - 1] < arr[i]:
			arr[i - 1] += 1
			m -= 1
			used = True
	if m > 0 and (not used):
		arr[len(arr) - 1] += 1
		m -= 1
	used = False
print(arr[n - 1], kmax)


n = int(input())
m = int(input())
max1 = 0
sum1 = 0
for i in range(n):
	a = int(input())
	sum1 += a
	max1 = max(max1, a)
val = n * max1 - sum1
if m > val:
	m1 = m - val
	val = m1 // n
	if m1 % n == 0:
		print(max1 + val, max1 + m)
	else:
		print(max1 + val + 1, max1 + m)
else:
	print(max1, max1 + m)


import math
n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
ans = min(a) + m
ans = min(ans, math.ceil((sum(a) + m) / n))
ans = max(ans, max(a))
print(ans, max(a) + m)


n = int(input())
m = int(input())
a = []
i = 0
while i < n:
	x = int(input())
	a.append(x)
	i += 1
maxi = max(a) + m
i = 0
while i < m:
	a[a.index(min(a))] = min(a) + 1
	i += 1
print(max(a), maxi)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
maxik = a[n - 1] + m
total = 0
for i in range(n - 1):
	total += a[n - 1] - a[i]
if m <= total:
	print(a[n - 1], maxik)
else:
	m -= total
	minik = a[n - 1] + m // n
	if m % n != 0:
		minik += 1
	print(minik, maxik)


from math import *
n = int(input())
m = int(input())
l = []
for u in range(n):
	l.append(int(input()))
s = sum(l) + m
c = ceil(s / n)
q = max(l)
k = 0
for i in range(n):
	f = l[i] + m
	if f > k:
		k = f
if c >= q:
	print(c, k)
else:
	print(q, k)


n = int(input())
m = int(input())
people = []
for x in range(n):
	people += [int(input())]
k_max = m + max(people)
people = sorted(people)
for i in range(m):
	pos = -1
	for j in range(n):
		if pos == -1 or people[j] < people[pos]:
			pos = j
	assert pos != -1
	people[pos] += 1
k_min = max(people)
print(k_min)
print(k_max)


n = int(input())
m = int(input())
vec = []
i = 0
soma = 0
maior = 0
while i < n:
	a = int(input())
	vec.append(a)
	soma += a
	if maior < a:
		maior = a
	i += 1
da = 0
i = 0
while i < n:
	if vec[i] < maior:
		da += maior - vec[i]
	i += 1
alocar = m - da if da <= m else 0
minimo = maior + alocar // n
if alocar % n != 0:
	minimo += 1
print('%d %d' % (minimo, maior + m))


def ch(x):
	res = 0
	for i in a:
		if x < i:
			return 0
		res += x - i
	return res >= m
n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a) + m
l = 0
r = 1000000000
while r - l > 1:
	mid = l + r >> 1
	if ch(mid):
		r = mid
	else:
		l = mid
print(r, ma)


def read():
	return int(input())

def benches(a, m):
	assert len(a) > 0
	n = len(a)
	a = sorted(a)
	b = a[-1]
	k_max = b + m
	for i in range(n):
		m -= b - a[i]
	if m <= 0:
		return (b, k_max)
	c = m // n
	if m % n > 0:
		c += 1
	return (b + c, k_max)

def main():
	n = read()
	m = read()
	a = []
	for i in range(n):
		a.append(read())
	(k1, k2) = benches(a, m)
	print(k1, k2)
main()


nn = int(input())
m = int(input())
ls = []
n = nn
while nn > 0:
	k = int(input())
	ls.append(k)
	nn = nn - 1
maxls = max(ls)
kq2 = m + maxls
for i in range(m):
	ls = sorted(ls)
	ls[0] = ls[0] + 1
kq1 = max(ls)
print(kq1, ' ', kq2)


n = int(input())
m = int(input())
sum = 0
mx = 0
for i in range(n):
	x = int(input())
	sum += x
	mx = max(x, mx)
if (sum + m) % n == 0:
	print(max(int((sum + m) / n), mx), mx + m)
else:
	print(max(int((sum + m) / n) + 1, mx), mx + m)


import math
n = int(input())
m = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
s = sum(arr)
mi = max(max(arr), int(math.ceil((s + m) / float(n))))
ma = max(arr) + m
print(mi, ma)


n = int(input())
m = int(input())
dic = {}
for i in range(n):
	dic[i + 1] = int(input())
max_k = m + max(dic.values())
min_k = 0
while m > 0:
	dic[min(dic, key=dic.get)] += 1
	m -= 1
min_k = max(dic.values())
print(min_k, max_k)


import sys
import math
numberOfBenches = int(sys.stdin.readline())
additionalPeople = int(sys.stdin.readline())
data = [int(sys.stdin.readline()) for _ in range(numberOfBenches)]
data.sort()
maxPeople = str(data[-1] + int(additionalPeople))
mostCrowdedBench = data[-1]
for i in range(len(data) - 1):
	diff = mostCrowdedBench - data[i]
	if additionalPeople >= diff:
		data[i] += diff
		additionalPeople -= diff
	else:
		additionalPeople = 0
		break
if additionalPeople != 0:
	minPeople = mostCrowdedBench + math.ceil(float(additionalPeople) / numberOfBenches)
else:
	minPeople = mostCrowdedBench
sys.stdout.write(str(minPeople) + ' ' + maxPeople)


from math import ceil
n = int(input())
m = int(input())
benches = []
for i in range(n):
	benches.append(int(input()))
maximum = max(benches) + m
print(max(max(benches), ceil((sum(benches) + m) / n)), maximum)


n = int(input(''))
sayi = int(input(''))
liste = []
for i in range(n):
	liste.append(int(input()))
maxi = 0
liste.sort()
maxi = sayi + liste[liste.__len__() - 1]
j = 0
while sayi > 0:
	if j == len(liste) - 1:
		break
	if int(liste[j]) == int(liste[len(liste) - 1]):
		j += 1
		continue
	liste[j] += 1
	sayi -= 1
j = 0
if sayi != 0:
	for i in range(sayi):
		liste[j] += 1
		j += 1
		if len(liste) == j:
			j = 0
liste.sort()
mini = liste[liste.__len__() - 1]
print(int(mini), maxi)


n = int(input())
m = int(input())
benches = [0] * n
for i in range(n):
	benches[i] = int(input())
maxP = max(benches) + m
i = 0
while m != 0:
	mnIndex = benches.index(min(benches))
	benches[mnIndex] += 1
	m -= 1
minP = max(benches)
print(minP, maxP)


mod = 10 ** 9 + 7
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()))
ls = lambda : list(input())
n = ii()
m = ii()
l = [0] * n
for i in range(n):
	l[i] = ii()
print(max(max(l), (sum(l) + m + n - 1) // n), max(l) + m)


from math import ceil
n = int(input())
m = int(input())
benches = []
for i in range(n):
	benches.append(int(input()))
maxans = max(benches) + m
benches.sort()
for i in range(len(benches)):
	m -= max(benches) - benches[i]
	benches[i] = max(benches)
	if m <= 0:
		break
if m > 0:
	minans = int(ceil(m / n)) + max(benches)
else:
	minans = max(benches)
print(minans, end=' ')
print(maxans)


from sys import stdin, stdout
from collections import Counter

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

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

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
m = ip()
a = [ip() for i in range(n)]
b = a[:]
for i in range(m):
	a[a.index(min(a))] += 1
print(max(a), max(b) + m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
maximum = max(a)
sum_a = sum(a)
k_max = m + maximum
if n * maximum - sum_a >= m:
	k_min = maximum
else:
	q = m - (n * maximum - sum_a)
	k_min = maximum + q // n
	if q % n == 0:
		k_min = k_min
	else:
		k_min = k_min + 1
print(k_min, k_max)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 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 main():
	n = I()
	m = I()
	a = [I() for _ in range(n)]
	t = max(max(a), (sum(a) + m + n - 1) // n)
	u = max(a) + m
	return '{} {}'.format(t, u)
print(main())


def main():
	bancos = int(input(''))
	m = int(input(''))
	b = bancos
	maxi = 0
	kmin = 0
	kmax = 0
	lista = []
	while b > 0:
		ai = int(input(''))
		if ai > maxi:
			maxi = ai
		lista.append(ai)
		b -= 1
	kmin = calcularKMin(lista, m)
	kmax = maxi + m
	print(kmin, kmax)

def calcularKMin(lista, m):
	lista.sort()
	for x in range(m):
		lista[0] += 1
		lista.sort()
	return lista[-1]
main()


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
if max(a) * n - sum(a) >= m:
	print(max(a), end=' ')
else:
	r = m - (max(a) * n - sum(a))
	an = max(a) + r // n
	if r % n != 0:
		an += 1
	print(an, end=' ')
print(max(a) + m)


import math
n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
(i, x) = (0, m)
while len(set(l)) > 1 and m > 0:
	if i == n:
		i = 0
	if l[i] < max(l):
		l[i] += 1
		m -= 1
	i += 1
print(max(l) + math.ceil(m / n), max(l) + x)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
x = m // n
max_a = max(a)
min_a = min(a)
ans = max_a
tmp = 0
for i in a:
	tmp += max_a - i
	if m < tmp:
		break
nm = m - tmp
if nm > 0:
	ans += nm // n if nm % n == 0 else nm // n + 1
print('{} {}'.format(ans, max_a + m))


from sys import stdin, stdout
import cProfile, math
printHeap = str()
test = False
memory_constrained = False

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def test_print(output):
	if test:
		stdout.write(str(output) + '\n')

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
from collections import Counter

def main():
	n = get_int()
	m = get_int()
	li = list()
	for i in range(n):
		li.append(get_int())
	mini = max(li) if sum(li) + m <= max(li) * n else math.ceil((sum(li) + m) / n)
	print(mini, max(li) + m)
cProfile.run('main()') if test else main()


n = int(input())
m = int(input())
mx = 0
a = [0 for i in range(10102)]
for i in range(n):
	j = int(input())
	if j > mx:
		mx = j
	a[j] += 1
p = mx
mx += m
i = 0
while m > 0:
	m -= a[i]
	a[i + 1] += a[i]
	i += 1
print(max(p, i), mx)


import os
import sys
from io import BytesIO, IOBase
from math import ceil, floor
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
from math import ceil

def main():
	n = inp()
	m = inp()
	mx = 0
	summ = 0
	a = []
	for _ in range(n):
		temp = inp()
		summ += temp
		mx = max(mx, temp)
		a.append(temp)
	for i in range(m):
		i = a.index(min(a))
		a[i] += 1
	print(max(a), mx + m)
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()


def main():
	n = int(input())
	m = int(input())
	per_bench = [int(input()) for i in range(n)]
	per_bench.sort()
	max_k = per_bench[len(per_bench) - 1] + m
	for i in range(m):
		per_bench.sort()
		per_bench[0] = per_bench[0] + 1
	per_bench.sort()
	min_k = per_bench[len(per_bench) - 1]
	print(str(min_k) + ' ' + str(max_k))
main()


n = int(input())
new = int(input())
lavki = []
for number in range(n):
	lavki.append(int(input()))
maxi = max(lavki) + new
while new > 0:
	for num in range(min(new, n)):
		lavki[lavki.index(min(lavki))] = lavki[lavki.index(min(lavki))] + 1
		new = new - 1
print(max(lavki), maxi)


benches = int(input())
people = int(input())
a = list(map(int, [input() for _ in range(benches)]))
m = max(a) + people
a.sort()
while people > 0:
	a[0] += 1
	people -= 1
	i = 0
	while i < benches - 1 and a[i] > a[i + 1]:
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		i += 1
print(a[-1], m)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mx = max(a) + m
while m:
	for i in range(n):
		if a[i] == min(a):
			a[i] += 1
			m -= 1
			break
print(max(a), mx)


import math
for i in range(1):
	n = int(input())
	m = int(input())
	l = []
	s = 0
	for i in range(n):
		k = int(input())
		s += k
		l.append(k)
	print(max((m + s + n - 1) // n, max(l)), max(l) + m)


import math
n = int(input())
m = int(input())
benches = []
biggest = 0
for i in range(0, n):
	temp = int(input())
	biggest = max(biggest, temp)
	benches.append(temp)
maximumK = biggest + m
myBool = False
for i in range(0, n):
	if m > 0:
		if benches[i] < biggest:
			m -= biggest - benches[i]
	else:
		myBool = True
		break
minimumK = 0
if m <= 0:
	minimumK = biggest
else:
	minimumK = biggest + math.ceil(m / n)
print(str(minimumK) + ' ' + str(maximumK))


NBancas = int(input())
GenteQueLlega = int(input())
EspaciosOcupadosxBanca = {}
for i in range(NBancas):
	Entrada = input()
	EspaciosOcupadosxBanca.update({i: int(float(Entrada))})
key = max(EspaciosOcupadosxBanca, key=EspaciosOcupadosxBanca.get)
maximo = EspaciosOcupadosxBanca[key] + GenteQueLlega
for i in range(GenteQueLlega):
	key = min(EspaciosOcupadosxBanca, key=EspaciosOcupadosxBanca.get)
	EspaciosOcupadosxBanca.update({key: EspaciosOcupadosxBanca[key] + 1})
key = max(EspaciosOcupadosxBanca, key=EspaciosOcupadosxBanca.get)
minimo = EspaciosOcupadosxBanca[key]
print(str(minimo) + ' ' + str(maximo))


n = int(input())
m = int(input())
import math
arr = []
for i in range(n):
	arr.append(int(input()))
maxy = max(arr) + m
miny = max(arr)
if miny * n - sum(arr) < m:
	t = (m - (miny * n - sum(arr))) / n
	miny = miny + math.ceil(t)
print('{0} {1}'.format(miny, maxy))


ben_n = int(input())
ben_list = [None] * ben_n
ppl = int(input())
for index in range(ben_n):
	ben_list[index] = int(input())
max_p = max(ben_list) + ppl
for person in range(ppl):
	ben_list[ben_list.index(min(ben_list))] += 1
min_p = max(ben_list)
print(str(min_p) + ' ' + str(max_p))


import math
a = int(input())
b = int(input())
ben = []
for i in range(a):
	ben += [int(input())]
ben.sort()
s = b
t = 0
for i in range(a - 1):
	k = ben[i + 1] - ben[i]
	if k * (i + 1) > s:
		t = 1
		break
	s -= k * (i + 1)
if t == 1:
	print(max(ben), max(ben) + b)
else:
	print(max(ben) + math.ceil(s / a), max(ben) + b)


n = int(input())
m = int(input())
a = sorted([int(input()) for i in range(n)])
ans2 = max(a) + m
for i in range(n):
	m -= a[-1] - a[i]
	a[i] += a[-1] - a[i]
ans1 = a[-1] if m <= 0 else a[-1] + (m + n - 1) // n
print(ans1, ans2)


n = int(input())
m = int(input())
summ = 0
maxx = 0
for i in range(n):
	a = int(input())
	if a > maxx:
		maxx = a
	summ += a
ans = (summ + m) // n
if (summ + m) % n:
	ans = (summ + m) // n + 1
print(max(ans, maxx), maxx + m)


(n, m) = (int(input()), int(input()))
mm = m
l = [int(input()) for i in range(n)]
sm = sum(l)
p = max(l) * n
if m <= p - sm:
	mn = max(l)
else:
	m -= p - sm
	mn = max(l) + m // n
	if m % n:
		mn += 1
mx = max(l) + mm
print(mn, mx)


import math
R = input
n = int(R())
m = int(R())
a = []
for i in range(0, n):
	temp = R()
	a.append(int(temp))
Sum = max(a) + m
p = int(math.ceil(float(sum(a) + m) / float(n)))
if p < max(a):
	p = max(a)
print(p, Sum)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
mx = max(a)
s = 0
for i in range(n):
	s += mx - a[i]
print(mx if s >= m else mx + (m - s) // n + ((m - s) % n != 0), end=' ')
print(mx + m)


from math import ceil
n = int(input())
m = int(input())
(ma, total) = (0, 0)
for i in range(n):
	s = int(input())
	if s > ma:
		ma = s
	total += s
print(max(ma, ceil((m - (ma * n - total)) / n + ma)), m + ma)


(n, m) = (int(input()), int(input()))
(a, i) = ([int(input()) for i in range(n)], 0)
a.sort()
(mx, mn) = (a[len(a) - 1] + m, a[len(a) - 1])
while m > 0 and i < len(a):
	(m, i) = (m - (mn - a[i]), i + 1)
while m > 0:
	(m, mn) = (m - len(a), mn + 1)
print(mn, mx)


from math import ceil
n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
maxx = max(arr)
difference = maxx * n - sum(arr)
if difference >= m:
	smallest = maxx
else:
	smallest = ceil((m - difference) / n) + maxx
largest = maxx + m
print('{} {}'.format(smallest, largest))


n = int(input())
m = int(input())
cm = m
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
x = a[n - 1]
for i in range(n):
	y = x - a[i]
	m = m - y
	a[i] = a[i] + y
p = 0
ma = max(a)
if m > 0:
	p = m // n
	if m % n == 0:
		p = p
	else:
		p = p + 1
	print(p + ma, end=' ')
else:
	print(ma, end=' ')
print(x + cm)


gi = lambda : list(map(int, input().split()))
(n,) = gi()
(x,) = gi()
l = []
for k in range(n):
	l.append(gi()[0])
ma = max(l) + x
cur = 0
while x > 0:
	if l[cur] <= min(l):
		x -= 1
		l[cur] += 1
	cur += 1
	cur = cur % n
mi = max(l)
print(str(mi) + ' ' + str(ma))