The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.

Help him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.


-----Input-----

The first line contains two integers $n$ and $s$ ($1 \le n \le 10^3$, $1 \le s \le 10^{12}$) — the number of kegs and glass volume.

The second line contains $n$ integers $v_1, v_2, \ldots, v_n$ ($1 \le v_i \le 10^9$) — the volume of $i$-th keg.


-----Output-----

If the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.


-----Examples-----
Input
3 3
4 3 5

Output
3

Input
3 4
5 3 4

Output
2

Input
3 7
1 2 3

Output
-1



-----Note-----

In the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.

In the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.

In the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.

Difficulty: EASY

Solutions:
(n, s) = map(int, input().split())
v = [int(k) for k in input().split()]
v.sort(reverse=True)
for i in range(n):
	s -= v[i] - v[-1]
	v[i] = v[-1]
if s <= 0:
	print(v[-1])
elif s > n * v[0]:
	print(-1)
else:
	print(v[0] - (s + n - 1) // n)


import math
(n, s) = list(map(int, input().split()))
v = list(map(int, input().split()))
sum_v = sum(v)
if sum_v < s:
	print(-1)
else:
	v.sort()
	minimum = v[0]
	remaining = s - (sum_v - n * minimum)
	if remaining <= 0:
		print(minimum)
	else:
		print(minimum - int(math.ceil(remaining / n)))


(n, s) = map(int, input().split())
u = list(map(int, input().split()))
mu = min(u)
su = sum(u)
if su < s:
	print(-1)
else:
	s -= su - mu * n
	if s <= 0:
		print(mu)
	else:
		k = s // n
		if s % n != 0:
			k += 1
		print(mu - k)


(x, s) = list(map(int, input().split()))
l = list(map(int, input().split()))
sum = 0
for i in l:
	sum += i
if sum < s:
	print(-1)
elif sum == s:
	print(0)
else:
	k = sum - len(l) * min(l)
	if k >= s:
		print(min(l))
	else:
		sum -= k
		s -= k
		ans = s // len(l)
		if s % len(l) != 0:
			ans += 1
		print(min(l) - ans)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
y = min(a) * n
x = sum(a)
if x < s:
	print(-1)
elif s <= x - y:
	print(y // n)
else:
	s = s - (x - y)
	print((y - s) // n)


(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
mn = min(arr)
sm = sum(arr)
if sm < s:
	print(-1)
elif sm == s:
	print(0)
else:
	avg = (sm - s) // n
	print(min(mn, avg))


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


(N, S) = map(int, input().split())
L = list(map(int, input().split()))
x = 0
for i in range(N):
	x += L[i] - min(L)
if x >= S:
	print(min(L))
elif S > sum(L):
	print('-1')
else:
	y = S - x
	if y // N == y / N:
		k = y // N
		print(min(L) - k)
	else:
		k = y // N + 1
		print(min(L) - k)


(a, b) = map(int, input().split())
z = list(map(int, input().split()))
s = sum(z)
r = min(z)
if b > s:
	print(-1)
else:
	print(min(r, (s - b) // a))


import math
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
least = min(v)
if sum(v) < s:
	print(-1)
else:
	for i in v:
		s -= i - least
	if s > 0:
		least -= (s + n - 1) / n
	print(math.ceil(least))


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < k:
	print(-1)
else:
	t = 0
	m = min(l)
	for i in range(n):
		t += l[i] - m
		l[i] = m
	if t >= k:
		print(m)
	else:
		k -= t
		t = ceil(k / n)
		print(m - t)


def solve(n, vol, kegs):
	if sum(kegs) < vol:
		return -1
	totalVolume = sum(kegs)
	allMin = min(kegs) * n
	finalVolume = totalVolume - vol
	if finalVolume >= allMin:
		return min(kegs)
	return int(finalVolume / n)
(n, vol) = list(map(int, input().split()))
kegs = list(map(int, input().split()))
print(solve(n, vol, kegs))


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) < s:
	print(-1)
	exit(0)
mv = min(v)
for i in range(n):
	s -= v[i] - mv
if s < 1:
	print(mv)
	exit(0)
ans = mv - s // n
if s % n != 0:
	ans -= 1
print(ans)


def doit():
	xx = input().split()
	n = int(xx[0])
	s = int(xx[1])
	v = [int(k) for k in input().split()]
	S = sum(v)
	newS = S - s
	if newS < 0:
		return -1
	return min(newS // n, min(v))
print(doit())


(n, s) = map(int, input().split())
v = sorted(list(map(int, input().split())))
m = min(v)
ss = sum(v)
if s > ss:
	print(-1)
elif s <= ss - n * m:
	print(m)
else:
	s = s - ss + n * m
	print(m - s // n - int(bool(s % n)))


(n, m) = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
if sum(v) < m:
	print(-1)
else:
	st = 0
	en = min(v) + 1
	while st < en:
		mid = (st + en) // 2
		cnt = 0
		for i in v:
			cnt += i - mid
		if cnt >= m:
			st = mid + 1
		else:
			en = mid
	print(st - 1)


import math
(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
if sum(arr) < s:
	print('-1')
else:
	mn = min(arr)
	sm = [x - mn for x in arr]
	sum_arr = sum(sm)
	if sum_arr >= s:
		print(mn)
	else:
		s -= sum_arr
		c = s / n
		print(mn - math.ceil(c))


(n, s) = map(int, input().split())
arrv = list(map(int, input().split()))
(sumv, minv) = (sum(arrv), min(arrv))
if sumv < s:
	print(-1)
else:
	k = (sumv - s) // n
	print(min(k, minv))


(n, s) = map(int, input().split())
a = [int(i) for i in input().split()]
mini = min(a)
t = 0
for i in range(n):
	t = t + a[i] - mini
if t >= s:
	print(mini)
elif s > sum(a):
	print('-1')
else:
	rem = s - t
	if rem // n == rem / n:
		k = rem // n
		print(mini - k)
	else:
		k = rem // n + 1
		print(mini - k)


(n, s) = list(map(int, input().split()))
a = list(map(int, input().split()))
if s > sum(a):
	print(-1)
elif s == sum(a):
	print(0)
else:
	a = sorted(a)
	total = sum(a)
	b = [0 for _ in range(len(a))]
	b[0] = a[0]
	for i in range(1, len(a)):
		b[i] = a[i] + b[i - 1]
	c = [0 for _ in range(len(a))]
	c[0] = total - a[0] * len(a)
	for i in range(1, len(a)):
		c[i] = total - b[i] - a[i] * (len(a) - i - 1)
	if s <= c[0]:
		print(a[0])
	else:
		s -= c[0]
		add = s // len(a) + bool(s % len(a))
		final = a[0] - add
		print(final)


((n, s), v) = (map(int, input().split()), tuple(map(int, input().split())))
(minv, sumv) = (min(v), sum(v))
maxminv = (sumv - s) // n
print(-1 if s > sumv else minv if minv < maxminv else maxminv)


(n, s) = map(int, input().split())
u = [int(x) for x in input().split()]
su = sum(u)
if su < s:
	print(-1)
elif su == s:
	print(0)
else:
	u.sort()
	print(min((su - s) // n, u[0]))


(n, s) = map(int, input().split())
lis = list(map(int, input().split()))
if s > sum(lis):
	print(-1)
	exit()
lis.sort(reverse=True)
i = 0
while i < n and s > 0:
	if s < lis[i] - lis[-1]:
		print(lis[-1])
		exit()
	s -= lis[i] - lis[-1]
	lis[i] = lis[-1]
	i += 1
if s == 0:
	print(lis[-1])
elif s % n == 0:
	print(lis[-1] - s // n)
else:
	print(lis[-1] - s // n - 1)


from sys import stdin
import math
(n, s) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
arr.sort()
mn = min(arr)
diff = 0
for i in range(1, n):
	diff += arr[i] - mn
if diff >= s:
	print(mn)
	exit()
elif diff + mn * n >= s:
	s -= diff
	print(mn - math.ceil(s / n))
else:
	print(-1)


(n, s) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
sum = 0
min = a[0]
for i in range(n):
	if min > a[i]:
		min = a[i]
	sum += a[i]
if sum < s:
	print('-1')
elif sum == s:
	print('0')
elif s <= sum - n * min:
	print(min)
else:
	s -= sum - n * min
	ans = (n * min - s) // n
	print(ans)


(n, s) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
if sum(a) < s:
	print(-1)
else:
	a.sort()
	s -= sum(a) - a[0] * n
	if s < 1:
		print(a[0])
	elif s % n == 0:
		print(a[0] - s // n)
	else:
		print(a[0] - s // n - 1)


def _1084B():
	(n, s) = map(int, input().split())
	aa = list(map(int, input().split()))
	mn = min(aa)
	if sum(aa) < s:
		return -1
	totdif = 0
	for i in range(n):
		totdif += aa[i] - mn
	if s <= totdif:
		return mn
	s -= totdif
	(q, r) = (s // n, s % n)
	return mn - q if r == 0 else mn - q - 1
print(_1084B())


line = input()
(n, s) = [int(x) for x in line.split()]
line = input()
vs = [int(x) for x in line.split()]
sm = sum(vs)
if sm < s:
	print(-1)
else:
	mn = min(vs)
	tot = sum([x - mn for x in vs])
	if tot < s:
		diff = s - tot
		mn -= int(diff / n)
		dv = 1 if diff % n > 0 else 0
		mn -= dv
	print(mn)


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

def check(x):
	global s
	tot = 0
	for i in a:
		tot += i - x
	return tot >= s
sum = 0
mi = 1000000000.0
for i in a:
	sum += i
	mi = min(mi, i)
if sum < s:
	print(-1)
else:
	l = 0
	r = mi
	ans = r
	while r >= l:
		m = (l + r) // 2
		if check(m):
			l = m + 1
			ans = m
		else:
			r = m - 1
	print(int(ans))


I = lambda : map(int, input().split())
(n, s) = I()
l = list(I())
x = min(l)
total = 0
for i in range(n):
	total += l[i] - x
y = s - total
if y <= 0:
	print(x)
else:
	z = y // n
	a = y % n
	if a == 0:
		x = x - z
	else:
		z = z + 1
		x = x - z
	if x < 0:
		print(-1)
	else:
		print(x)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def tryLeastkeg(mink):
	i = n - 1
	k = 0
	t = 0
	while i >= 0:
		if v[i] > mink:
			t = t + (v[i] - mink)
			k = k + 1
			if t >= s:
				return True
		i = i - 1
	return False

def main():
	global n, s, v, res
	(n, s) = [int(x) for x in stdin.readline().split()]
	v = [int(x) for x in stdin.readline().split()]
	v.sort()
	l = 0
	r = min(v)
	res = -1
	while l <= r:
		mid = floor((l + r) / 2)
		if tryLeastkeg(mid) == True:
			if res < 0:
				res = mid
			else:
				res = max(res, mid)
			l = mid + 1
		else:
			r = mid - 1
	stdout.write(str(res))
	return 0
main()


(n, s) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
summa = sum(a)
if summa < s:
	print(-1)
else:
	answer = (summa - s) // len(a)
	if answer > min(a):
		answer = min(a)
	print(answer)


import math
(n, q) = list(map(int, input().split()))
h = list(map(int, input().split()))
t = 0
for i in range(n):
	t += h[i]
if t < q:
	print(-1)
	return
low = min(h)
for i in range(n):
	q -= h[i] - low
if q <= 0:
	print(low)
	return
low -= math.ceil(q / n)
print(low)


(n, k) = map(int, input().split())
a = []
a = list(map(int, input().split()))
mi = min(a)
su = sum(a)
if su < k:
	print(-1)
else:
	print(min(mi, (su - k) // n))


def retarray():
	return list(map(int, input().split()))
import math
(n, s) = retarray()
a = retarray()
min_keg = min(a)
acc = 0
for x in a:
	acc += x - min_keg
if acc >= s:
	print(min_keg)
else:
	x = math.ceil((s - acc) / n)
	if x > min_keg:
		print(-1)
	else:
		print(min_keg - x)


(n, s) = map(int, input().strip().split())
v = list(map(int, input().strip().split()))
m = min(v)
for i in v:
	if s > 0:
		s -= i - m
from math import ceil
if m * n < s:
	print(-1)
elif s <= 0:
	print(m)
else:
	print(m - ceil(s / n))


import math
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, s) = mapin()
v = listin()
if sum(v) < s:
	print(-1)
elif sum(v) == s:
	print(0)
else:
	v.sort()
	t = sum(v) - v[0] * n
	if s <= t:
		print(v[0])
	else:
		s -= t
		v = [v[0]] * n
		k = math.ceil(s / n)
		print(v[0] - k)


import sys
from math import ceil
from os.path import isfile
(fin, fout) = (open('b.in'), open('b.out', 'w')) if isfile('b.in') else (sys.stdin, sys.stdout)

def ris():
	return map(int, fin.readline().split())

def ri():
	return int(fin.readline())
(n, s) = ris()
v = sorted(ris(), reverse=True)
mn = v[-1]
mn_i = n - 1
while mn_i > 0 and mn == v[mn_i]:
	mn_i -= 1
s -= sum((v[i] - mn for i in range(mn_i + 1)))
if s > 0:
	if mn >= ceil(s / n):
		mn -= ceil(s / n)
	else:
		mn = -1
fout.write('%d\n' % mn)
(fin.close(), fout.close())


(n, s) = list(map(int, input().split()))
v = list(map(int, input().split()))
sm = sum(v)
sm -= s
if sm < 0:
	print(-1)
else:
	mn = min(v)
	r = min(mn, sm // n)
	print(r)


import math
(n, s) = (int(s2) for s2 in input().split(' '))
kegs = [int(s2) for s2 in input().split(' ')]
min_keg = min(kegs)
overflow = sum((keg - min_keg for keg in kegs))
if s <= overflow:
	print(min_keg)
else:
	remaining = s - overflow
	n = int(math.ceil(remaining / len(kegs)))
	if n > min_keg:
		print(-1)
	else:
		print(min_keg - n)


(n, s) = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
b = [0 for i in range(n)]
rem = 0
if sum(v) < s:
	print(-1)
else:
	mn = min(v)
	m = mn
	for i in range(n):
		b[i] = v[i] - mn
	sm = sum(b)
	if sm >= s:
		print(mn)
	else:
		rem = s - sm
		times = rem // n
		rem -= times * n
		m -= times
		if rem == 0:
			print(m)
		else:
			print(m - 1)


import math
(n, s) = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
v.sort()
if sum(v) < s:
	print(-1)
else:
	ans = -1
	if s <= sum(v) - min(v) * n:
		print(min(v))
	else:
		s -= sum(v) - min(v) * n
		v = [min(v)] * n
		if s % n == 0:
			print(v[0] - s // n)
		else:
			print(v[0] - s // n - 1)


(n, s) = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < s:
	print(-1)
	exit()
q = sum(l) - min(l) * n
if q >= s:
	print(min(l))
	exit()
print(min(l) - (s - q + n - 1) // n)


import math
(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
m = min(arr)
suum = sum(arr)
if suum >= s:
	print(min((suum - s) // n, m))
else:
	print(-1)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
m = min(a)
l = 0
if sum(a) < s:
	print(-1)
if sum(a) > s:
	for i in range(n):
		l += a[i] - m
	if l >= s:
		print(m)
	else:
		res = s - l
		b = res // n
		m -= b
		if res % n != 0:
			m -= 1
		print(m)
if sum(a) == s:
	print(0)


(n, s) = map(int, input().split())
st = list(map(int, input().split()))
(a, b) = (sum(st), min(st))
if a < s:
	print(-1)
else:
	c = a - n * b
	if s <= c:
		print(b)
	else:
		print(b - (s - c + n - 1) // n)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
(m, s) = (min(l), sum(l))
if s < k:
	print(-1)
else:
	print(min(m, (s - k) // n))


(n, s) = map(int, input().split())
summ = 0
minn = 10000000000
for v in map(int, input().split()):
	minn = min(minn, v)
	summ += v
if summ < s:
	print('-1')
else:
	print(min(minn, (summ - s) // n))


(n, s) = map(int, input().split())
allCups = list(map(int, input().split()))
sumK = sum(allCups)
minK = min(allCups)
if sumK < s:
	print(-1)
elif sumK - minK * n >= s:
	print(minK)
else:
	s = s - (sumK - minK * n)
	if s % n == 0:
		print(minK - s // n)
	else:
		print(minK - s // n - 1)


from math import ceil
(n, s) = map(int, input().split())
l = [int(i) for i in input().split()]
sm = sum(l)
m = min(l)
if s > sm:
	print(-1)
	exit()
print(min(m, (sm - s) // n))


(n, s) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
total = sum(a)
if total < s:
	print(-1)
elif total == s or total - n < s:
	print(0)
else:
	m = min(a)
	if total - m * n >= s:
		print(m)
	else:
		s = s - (total - m * n)
		total = m * n
		print((total - s) // n)


line1 = [int(x) for x in input().split()]
line2 = [int(x) for x in input().split()]
n = line1[0]
v = line1[1]

def least_amount(n, v, line2):
	total = sum(line2)
	amount = min((total - v) // n, min(line2))
	return amount if amount >= 0 else -1
print(least_amount(n, v, line2))


R = lambda : map(int, input().split())
(n, s) = R()
v = [*R()]
m = min(v)
s = max(0, s - sum(v) + n * m)
print(max(-1, m + -s // n))


(n, s) = map(int, input().split())
sum = 0
lists = list(map(int, input().split()))
minimum = min(lists)
for i in lists:
	sum = sum + i
if sum < s:
	print('-1')
else:
	print(int(min((sum - s) / n, minimum)))


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, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

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)
	c = dict(Counter(l))
	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 sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

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 si():
	return input()

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

def solve():
	(n, s) = li()
	l = li()
	l.sort()
	ans = -1
	low = 0
	high = max(l)

	def check(mid):
		ans = 0
		for i in l:
			if i < mid:
				return False
			ans += i - mid
		if ans >= s:
			return True
		return False
	while low <= high:
		mid = (low + high) // 2
		if check(mid):
			low = mid + 1
			ans = mid
		else:
			high = mid - 1
	print(ans)
t = 1
for _ in range(t):
	solve()


import math
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
total = sum(arr)
if total < k:
	print(-1)
elif total == k:
	print(0)
else:
	smallest = min(arr)
	rem = total - n * smallest
	if rem >= k:
		print(smallest)
	else:
		rem = k - rem
		print(smallest - int(math.ceil(rem / n)))


(n, s) = tuple(map(int, input().split()))
min = 2000000000
arr = list(map(int, input().split()))
for i in range(n):
	if arr[i] < min:
		min = arr[i]
sum = 0
for i in range(n):
	sum = sum + (arr[i] - min)
flag = 0
if sum >= s:
	print(min)
else:
	tmp = s - sum
	tmpMin = tmp // n
	if min < tmpMin:
		tmpMin = min
	sum = sum + tmpMin * n
	min = min - tmpMin
	if sum >= s:
		print(min)
		flag = 1
	else:
		while min > 0:
			min = min - 1
			sum = sum + n
			if sum >= s:
				print(min)
				flag = 1
				break
	if flag == 0:
		print(-1)


from math import ceil
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
if s > sum(a):
	print(-1)
else:
	a.sort(reverse=True)
	i = 0
	sofa = 0
	mn = min(a)
	while i < n and a[i] != mn:
		sofa += a[i] - mn
		i += 1
	if sofa >= s:
		print(mn)
	else:
		diff = s - sofa
		print(mn - ceil(diff / n))


(m, n) = input().split(' ')
m = int(m)
n = int(n)
s = list(map(int, input().split(' ')))
t = 0
for i in s:
	t += i
t = t - n
t = t // m
less = 10 ** 9 + 1
for i in s:
	if i < less:
		less = i
if t < 0:
	print(-1)
elif less < t:
	print(less)
else:
	print(t)


import math
(n, s) = map(int, input().split(' '))
ar = list(map(int, input().split(' ')))
sm = sum(ar)
if s > sm:
	print(-1)
else:
	mn = min(ar)
	ex = sm - mn - (n - 1) * mn
	if ex < s:
		print(mn - math.ceil((s - ex) / n))
	else:
		print(mn)


def check(sum, n, x, s):
	if sum - n * x >= s:
		return True
	else:
		return False

def main():
	(n, s) = map(int, input().split())
	sum = 0
	minval = 999999999999
	a = input().split()
	for i in range(n):
		sum += int(a[i])
		minval = min(minval, int(a[i]))
	if sum < s:
		print(-1)
	else:
		l = 0
		r = minval
		ans = 0
		while l <= r:
			m = (l + r) // 2
			if check(sum, n, m, s):
				l = m + 1
				ans = max(ans, m)
			else:
				r = m - 1
		print(ans)
main()


(n, s) = map(int, input().split())
A = list(map(int, input().split()))
a = 0
ans = 0
if sum(A) < s:
	ans = -1
else:
	x = min(A)
	for i in range(0, n):
		if A[i] != x:
			a += A[i] - x
	if a >= s:
		ans = x
	else:
		c = s - a + n - 1
		c = c // n
		ans = x - c
print(ans)


(n, s) = map(int, input().split())
list = [int(i) for i in input().split()]
list.sort(reverse=True)
if sum(list) < s:
	print('-1')
	exit()
for i in range(n - 1):
	s -= list[i] - list[n - 1]
	list[i] = list[n - 1]
	if s <= 0:
		print(list[n - 1])
		exit()
if s <= n:
	print(list[0] - 1)
	exit()
elif s % n:
	print(list[0] - int(s / n) - 1)
else:
	print(list[0] - int(s / n))


import sys
import math
s = int(sys.stdin.readline().rstrip().split(' ')[1])
lne = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]
n = min(math.floor((sum(lne) - s) / len(lne)), min(lne))
if n >= 0:
	print(n)
else:
	print(-1)


(n, s) = [int(x) for x in input().split(' ')]
z = [int(x) for x in input().split(' ')]
z.sort()
if sum(z) < s:
	print(-1)
elif n == 1:
	print(z[0] - s)
else:
	(a, f) = (0, 0)
	for x in z[1:]:
		a += x - z[0]
		if a >= s:
			f = 1
			break
	if f:
		print(z[0])
	else:
		s -= a
		if s % n == 0:
			print(z[0] - s // n)
		else:
			print(z[0] - s // n - 1)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, groupby, zip_longest, permutations
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, s) = tup()
ls = lint()
S = sum(ls)
if s < s:
	print(-1)
elif s == S:
	print(0)
else:
	ls.sort(reverse=True)
	x = 0
	for i in range(n - 1):
		if x < s:
			p = min(s - x, ls[i] - ls[n - 1])
			x += p
			ls[i] = ls[i] - p
		else:
			break
	s -= x
	if s == 0:
		print(min(ls))
		exit()
	if s <= n:
		print(max(-1, min(ls) - 1))
	else:
		print(max(-1, ls[n - 1] - ceil(s / n)))
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


import math
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
t1 = sum(l)
if t1 < s:
	print('-1')
else:
	m = min(l)
	t2 = 0
	for i in range(len(l)):
		x = l[i] - m
		t2 = t2 + x
	if t2 > s:
		print(m)
	else:
		y = s - t2
		ts = math.ceil(y / len(l))
		min = m - ts
		print(min)


(n, s) = map(int, input().split())
us = input().split()
sum = 0
m = 10 ** 9 + 1
for u in us:
	sum += int(u)
	if int(u) < m:
		m = int(u)
if sum < s:
	print(-1)
elif (sum - s) // n < m:
	print((sum - s) // n)
else:
	print(m)


import sys
from math import ceil

def main():
	(n, s) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	if s > sum(arr):
		print(-1, sep=' ', end='\n', file=sys.stdout, flush=False)
	else:
		count = 0
		arr.sort(reverse=True)
		for i in range(n - 1):
			if count == s:
				break
			if count + (arr[i] - arr[-1]) <= s:
				count += arr[i] - arr[-1]
				arr[i] = arr[-1]
			elif count + (arr[i] - arr[-1]) > s:
				count = s
				arr[i] -= s - count
		if count == s:
			print(arr[-1])
		else:
			factor = (s - count) / n
			print(arr[-1] - ceil(factor), sep=' ', end='\n', file=sys.stdout, flush=False)

def __starting_point():
	main()
__starting_point()


import math
(n, s) = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
if sum(v) < s:
	print(-1)
	exit()
m = min(v)
for i in range(len(v)):
	s -= v[i] - m
if s <= 0:
	print(m)
else:
	print(m - (s + n - 1) // n)


(n, s) = map(int, input().split())
arr = [int(x) for x in input().split()]
if sum(arr) < s:
	print('-1')
	exit()
mn = min(arr)
extra = sum([x - mn for x in arr])
if extra >= s:
	print(mn)
else:
	print(mn - (s - extra + n - 1) // n)


gi = lambda : list(map(int, input().split()))
(n, s) = gi()
l = gi()
l.sort(reverse=True)
mii = min(l)
cur = 0
while s and cur < n:
	s -= l[cur] - mii
	cur += 1
cur = 0
if s < 0:
	print(mii)
	exit()
if s > mii * n:
	print(-1)
	exit()
temp = s // n
if s % n:
	temp += 1
print(mii - temp)


from math import ceil
(n, s) = map(int, input().split())
x = [int(v) for v in input().split()]
t = sum(x)
m = min(x)
if t < s:
	print(-1)
elif t - n * m >= s:
	print(m)
else:
	l = ceil((s - t + n * m) / n)
	print(m - l)


(n, s) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
h = sum(a)
if h > s:
	min = a[0]
	f = h - min * n
	if f >= s:
		print(min)
	else:
		print((h - s) // n)
elif h == s:
	print(0)
else:
	print(-1)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) < s:
	print(-1)
	exit()
v.sort()
a = v[0]
for i in range(n):
	s -= v[i] - a
if s <= 0:
	print(a)
else:
	b = a - 1 - (s - 1) // n
	if b > 0:
		print(b)
	else:
		print(0)


from heapq import heappop, heappush
t = 1
for test in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) < s:
		print(-1)
		continue
	heap = []
	for i in range(n):
		heappush(heap, (-a[i], i))
	if n == 1:
		print(a[0] - s)
		continue
	count = 1
	cur = heappop(heap)
	nex = heappop(heap)
	ans = -1
	while s > 0:
		while cur[0] == nex[0]:
			count += 1
			if len(heap) == 0:
				ans = (-1 * count * nex[0] - s) // count
				s = 0
				break
			nex = heappop(heap)
		s -= count * (-cur[0] + nex[0])
		cur = nex
	if ans == -1:
		heappush(heap, nex)
		print(-max(heap)[0])
	else:
		print(ans)


(n, k) = [int(j) for j in input().split()]
a = [int(j) for j in input().split()]
t = min(a)
summ = 0
for i in range(n):
	summ += a[i]
psumm = summ - t * n
ram = k - psumm
if ram % n == 0:
	ans = t - ram // n
else:
	ans = t - 1 - ram // n
if k > summ:
	print(-1)
elif k <= psumm:
	print(t)
else:
	print(ans)


import math
(n, s) = map(int, input().split())
li = input().split()
for i in range(n):
	li[i] = int(li[i])
su = sum(li)
if su < s:
	print(-1)
	exit(0)
if su - s < n:
	print(0)
	exit(0)
li.sort()
k = (su - s) / n
k = int(math.floor(k))
if k > li[0]:
	k = li[0]
print(k)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
(before, after, mini) = (0, 0, 10 ** 12)
for i in range(n):
	before += a[i]
	mini = min(mini, a[i])
after = before - s
if after < 0:
	print('-1')
	exit()
each = int(after / n)
if mini < each:
	print(mini)
else:
	print(each)


import sys
import math
import bisect

def solve(A, m):
	n = len(A)
	if sum(A) < m:
		return -1
	min_val = min(A)
	tmp = sum(A) - min_val * n
	if tmp >= m:
		return min_val
	m -= tmp
	ans = (min_val * n - m) // n
	return ans

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


(n, k) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
minV = min(a)
s = sum(a)
if k > s:
	print(-1)
else:
	rest = s - minV * n
	if rest >= k:
		print(minV)
	else:
		k -= rest
		sol = k // n
		if k % n:
			sol += 1
		print(minV - sol)


import math
ns = list(map(int, input().rstrip().split()))
n = ns[0]
s = ns[1]
data = list(map(int, input().rstrip().split()))
data.sort()
extras = [i - data[0] for i in data]
total = sum(data)
extratotal = sum(extras)
if s > total:
	print(-1)
elif extratotal >= s:
	print(data[0])
else:
	sub = math.ceil((s - extratotal) / n)
	print(data[0] - sub)


from itertools import cycle
(n, s) = [int(j) for j in input().split(' ')]
V = [int(j) for j in input().split(' ')]
V = sorted(V, reverse=True) + [0]
diffs = [V[i] - V[i + 1] for i in range(len(V) - 1)]
i = 0
last_i = len(V) - 2
for i in range(len(V) - 1):
	v = V[i]
	v_next = V[i + 1]
	diff = v - v_next
	if i == last_i:
		boch_vsego = len(V) - 1
		if s % boch_vsego:
			nado = s // boch_vsego + 1
		else:
			nado = s // boch_vsego
		if V[i] < nado:
			print(-1)
			break
		else:
			print(V[i] - nado)
			break
	else:
		s -= diff * (i + 1)
		if s <= 0:
			print(V[-2])
			break


(n, s) = map(int, input().split())
l = [*map(int, input().split())]
sm = sum(l)
if sm < s:
	print(-1)
	return
m = min(l)
s -= sm - m * n
if s <= 0:
	print(m)
else:
	print(m - (s + n - 1) // n)


import math
n = input().split()
a = input().split()
for i in range(int(n[0])):
	a[i] = int(a[i])
a.sort()
a = a[::-1]
v = int(n[1])
f = 0
mi = 0
for j in range(int(n[0])):
	if a[-1] != a[j]:
		v -= a[j] - a[-1]
		a[j] = a[-1]
	if v <= 0:
		print(a[-1] - f)
		break
if v > 0:
	if v > int(n[0]) * (a[0] - f):
		print(-1)
	else:
		print(a[-1] - math.ceil(v / int(n[0])))


(n, s) = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
if s > sum(y):
	print(-1)
elif s == sum(y):
	print(0)
else:
	m = min(y)
	bk = sum([i - m for i in y])
	if s <= bk:
		print(m)
	else:
		s1 = s - bk
		m -= s1 // n
		if s1 % n != 0:
			m -= 1
		print(m)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

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

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

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
TestCases = False
testingMode = False
optimiseForReccursion = False

def comp(li):
	return len(li)

def main():
	(n, k) = get_tuple()
	li = get_list()
	sm = sum(li)
	res = 0
	print(min(math.floor(Fraction(sm - k, n)), min(li))) if sm - k >= 0 else print(-1)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


(n, s) = map(int, input().split())
v = [int(x) for x in input().split()]
v.sort()
l = v[0]
for i in range(1, n):
	if v[i] > l:
		s -= v[i] - l
if s <= 0:
	print(v[0])
else:
	r = (s + n - 1) // n
	if r > v[0]:
		print(-1)
	else:
		print(v[0] - r)


import math
(ns, ss) = '3 4'.strip().split(' ')
(ns, ss) = input().strip().split(' ')
n = int(ns)
s = int(ss)
vstr = '5 3 4'.strip().split(' ')
vstr = input().strip().split(' ')
v = list(map(int, vstr))
min_v = min(v)
for i in range(n):
	if v[i] > min_v:
		s -= v[i] - min_v
		v[i] -= v[i] - min_v
	if s <= 0:
		break
if s <= 0:
	print(min_v)
elif n * min_v < s:
	print(-1)
else:
	print(min_v - math.ceil(s / n))


(n, s) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l.reverse()
k = min(l)
x = 0
if s > sum(l):
	print(-1)
	exit()
for i in range(len(l)):
	if l[i] > k:
		s -= l[i] - k
		l[i] = k
if s > 0:
	if s % len(l) != 0:
		tt = s // len(l)
		tt += 1
	else:
		tt = s // len(l)
	s -= tt * len(l)
	l[0] -= tt
print(min(l))


import math, sys
(n, s) = map(int, input().split())
minval = math.inf
c = 0
l = list(map(int, input().split()))
add = sum(l)
if add < s:
	print(-1)
	sys.exit()
for i in range(0, n):
	v = l[c]
	minval = min(v, minval)
	c += 1
var = (add - s) / n
print(int(min(var, minval)))


import math
(n, s) = input().split()
(n, s) = (int(n), int(s))
a = [int(i) for i in input().split()]
a.sort()
for i in range(n):
	if a[i] > a[0]:
		s -= a[i] - a[0]
		if s <= 0:
			print(a[0])
			break
if a[0] * n < s:
	print(-1)
elif s > 0:
	print(a[0] - math.ceil(s / n))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict

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

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

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

def stringIn():
	return stdin.readline().strip()
(n, s) = listIn()
v = listIn()
if sum(v) < s:
	print(-1)
	exit(0)
m = min(v)
v.sort()
total_diff = 0
for i in range(n):
	total_diff += v[i] - m
if s <= total_diff:
	print(m)
else:
	s -= total_diff
	c = s // n
	s -= n * c
	m -= c
	if s > 0:
		m -= 1
	print(m)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) >= s:
	c = min(v)
	for i in range(n):
		s -= v[i] - c
		v[i] = c
	if s <= 0:
		print(v[0])
	else:
		print(v[0] - (s + n - 1) // n)
else:
	print(-1)


x = input()
n = int(x.split(' ')[0])
s = int(x.split(' ')[1])
x = input()
x = x.split(' ')
arr = [int(i) for i in x]
if sum(arr) < s:
	print('-1')
else:
	imin = min(arr)
	x = (sum(arr) - s) // n
	print(min(imin, x))


(n, s) = input().split()
n = int(n)
s = int(s)
arr = input().split()
for i in range(n):
	arr[i] = int(arr[i])
minim = min(arr)
count = arr.index(minim)
max = 0
for i in range(n):
	max += arr[i]
flag = 0
if s > max:
	print('-1')
else:
	for i in range(n):
		s -= arr[i] - minim
	if s <= 0:
		print(minim)
	else:
		print(minim - (s + n - 1) // n)


from sys import stdin, stdout
(n, s) = map(int, stdin.readline().split())
v = list(map(int, stdin.readline().split()))
ans = -1
if sum(v) < s:
	ans = -1
else:
	mnm = min(v)
	for i in range(n):
		if v[i] > mnm:
			if s - v[i] + mnm <= 0:
				ans = mnm
				s = 0
				break
			else:
				s = s - v[i] + mnm
				v[i] = mnm
	if s != 0:
		ans = mnm - s // n
		if s % n > 0:
			ans -= 1
stdout.write('{}'.format(ans))


(n, s) = map(int, input().split())
a = [int(i) for i in input().split()]
if sum(a) < s:
	print(-1)
	exit()
if sum(a) - n * min(a) >= s:
	print(min(a))
	exit()
s -= sum(a) - n * min(a)
if s % n == 0:
	print(min(a) - s // n)
else:
	print(min(a) - s // n - 1)


(n, s) = map(int, input().split())
a = [int(i) for i in input().split()]
x = sum(a)
if x >= s:
	print(min((x - s) // n, min(a)))
else:
	print('-1')


import sys
(a, b) = input().split()
(a, b) = (int(a), int(b))
k = input().split()
kk = k[:]
k = []
sum = 0
for i in kk:
	a = int(i)
	sum += a
	k.append(a)
if sum < b:
	print(-1)
	sys.exit()
k.sort()
least = k[0]
summ = sum - least * len(k)
k = [least for i in k]
if summ >= b:
	print(least)
	sys.exit()
else:
	b -= summ
	least -= b // len(k) + (1 if b % len(k) > 0 else 0)
	print(least)


(n, s) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
minb = min(b)
if sum(b) - minb * len(b) >= s:
	print(minb)
elif sum(b) - minb * len(b) < s:
	s -= sum(b) - minb * len(b)
	ot = minb - s // len(b)
	if s % len(b) != 0:
		ot -= 1
	if ot >= 0:
		print(ot)
	else:
		print(-1)


from math import floor
(n, s) = tuple((int(i) for i in input().split(' ')))
v_i = tuple((int(i) for i in input().split(' ')))
v_sum = sum(v_i)
if s > v_sum:
	print(-1)
else:
	print(min(floor((v_sum - s) / n), min(v_i)))


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
a = sum(v)
if a < s:
	print(-1)
else:
	z = min(v)
	a -= s
	print(min(z, a // n))


line1 = input()
tokens = line1.split()
n = int(tokens[0])
v = int(tokens[1])
line2 = input()
tokens = line2.split()
lst = []
for j in range(n):
	lst.append(int(tokens[j]))
minv = min(lst)
total = sum(lst)
if total < v:
	print('-1')
else:
	minv = min(int((total - v) / n), minv)
	print(minv)


(n, v) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
mina = min(a)
vm = sum(a) - n * mina
if v <= vm:
	print(mina)
elif sum(a) >= v > vm:
	print(mina + -(v - vm) // n)
else:
	print('-1')


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
minn = 1061109567
sum = 0
for i in range(n):
	minn = min(minn, a[i])
	sum += a[i]
if sum < s:
	print(-1)
else:
	print(int(min(minn, (sum - s) / n)))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
d = min(l)
for i in l:
	s = s + i
if s < m:
	print(-1)
else:
	print(min(d, (s - m) // n))


from math import ceil
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
sm = min(a)
diff = 0
if sum(a) < s:
	print(-1)
	exit(0)
for i in a:
	diff += i - sm
if diff >= s:
	print(sm)
else:
	rem = s - diff
	if diff == 0:
		print(a[0] - int(ceil(s / n)))
	else:
		to_rem = int(ceil(rem / n))
		print(sm - to_rem)


import heapq as h
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
if sum(v) < s:
	print(-1)
else:
	h.heapify(v)
	i = -1
	while i >= -n and s:
		s -= min(s, v[i] - v[0])
		v[i] -= min(s, v[i] - v[0])
		i -= 1
	v[0] -= s // n + (1 if s % n else 0)
	print(v[0])


import math
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < s:
	print(-1)
else:
	x = min(l)
	i = 0
	while i < len(l) and s > 0:
		s = s - (l[i] - x)
		i += 1
	if s == 0 or s < 0:
		print(x)
		exit()
	if s > 0:
		print(x - math.ceil(s / n))
		exit()


(n, V) = map(int, input().split())
s = list(map(int, input().split()))
if sum(s) < V:
	print(-1)
else:
	s.sort()
	summ = 0
	m = min(s)
	F = False
	for el in s[1:]:
		summ += el - m
		if summ >= V:
			F = True
			break
	if F:
		print(m)
	else:
		ost = V - summ
		print(int(m - ost / len(s)))


from math import ceil
(n, s) = list(map(int, input().split()))
liter_li = list(map(int, input().split()))
if sum(liter_li) < s:
	print(-1)
elif s <= sum(liter_li) - min(liter_li) * n:
	print(min(liter_li))
else:
	s -= sum(liter_li) - min(liter_li) * n
	a = int(ceil(s / n))
	print(min(liter_li) - a)


(n, s) = list(map(int, input().split()))
arr = list(map(int, input().split()))
if sum(arr) < s:
	print(-1)
else:
	arr.sort()
	now = 0
	minn = arr[0]
	for i in range(len(arr) - 1, 0, -1):
		if now >= s:
			break
		else:
			now += arr[i] - minn
	rem = s - now
	if rem <= 0:
		print(minn)
	elif rem <= len(arr):
		print(minn - 1)
	elif rem % len(arr) == 0:
		print(minn - rem // n)
	else:
		diff = rem // n + 1
		print(minn - diff)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations

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

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

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

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	print(factors)
	if len(factors) == 2:
		return True
	else:
		return False

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

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

def minimum_integer_not_in_list(a):
	b = max(a)
	if b < 1:
		return 1
	A = set(a)
	B = set(range(1, b + 1))
	D = B - A
	if len(D) == 0:
		return b + 1
	else:
		return min(D)

def solution():
	(n, s) = Mint()
	a = List()
	if sum(a) < s:
		print(-1)
	else:
		print(min(min(a), (sum(a) - s) // n))
solution()


from math import *
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
m = min(v)
s -= sum(v) - m * n
print(m if s <= 0 else m - ceil(s / n) if s <= m * n else -1)


def f(a):
	return a - MIN
(n, s) = list(map(int, input().split()))
v = list(map(int, input().split()))
if s > sum(v):
	print(-1)
else:
	MIN = min(v)
	new_v = list(map(f, v))
	S = sum(new_v)
	if S >= s:
		print(MIN)
	else:
		s -= S
		k = (s - 1) // n + 1
		print(MIN - k)


from math import ceil
(n, s) = list(map(int, input().split()))
A = list(map(int, input().split()))
if sum(A) < s:
	print(-1)
else:
	x = min(A)
	y = 0
	for k in range(n):
		y += A[k] - x
	if y >= s:
		print(x)
	else:
		a = s - y
		print(x - ceil(a / n))


def kvas(s, lst):
	(ss1, ss2) = (sum(lst), 0)
	if ss1 < s:
		return -1
	a = sorted(lst)
	for i in range(len(a)):
		ss2 += a[i] - a[0]
	if ss2 > s:
		return a[0]
	return a[0] - (s - ss2 + len(lst) - 1) // len(lst)
(N, S) = [int(j) for j in input().split()]
b = [int(z) for z in input().split()]
print(kvas(S, b))


def get_ans(n, s, a):
	sum = 0
	Min = int(1000000000.0 + 1)
	for elem in a:
		sum += elem
		Min = min(Min, elem)
	if sum < s:
		return -1
	k = (sum - s) // n
	return min(Min, k)
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
print(get_ans(n, s, a))


(n, s) = map(int, input().split())
values = list(map(int, input().split()))
m_v = min(values)
total = sum(values)
if total < s:
	print('{}'.format(-1))
	exit(0)
if total - n * m_v >= s:
	print('{}'.format(m_v))
	exit(0)
rest = s - (total - n * m_v)
r_p = rest % n
r_q = rest // n
if r_p:
	r_q += 1
print('{}'.format(m_v - r_q))


(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
x = sum(arr)
y = min(arr)
if x < s:
	print(-1)
else:
	z = x - y * n
	if z < s:
		s -= z
		if s % n == 0:
			print(y - s // n)
		else:
			print(y - s // n - 1)
	else:
		print(y)


(n, s) = list(map(int, input().split()))
kegs = list(map(int, input().split()))
if sum(kegs) < s:
	print(-1)
else:
	kegs.sort(reverse=True)
	i = 0
	while s > 0:
		diff = kegs[i] - kegs[n - 1]
		if diff > 0:
			s -= diff
			kegs[i] -= diff
			if i < n - 2:
				i += 1
		elif s > n:
			temp = s // n
			s -= temp * n
			kegs = [k - temp for k in kegs]
		else:
			kegs[0] -= 1
			s = 0
	print(min(kegs))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

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

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

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

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
for _ in range(1):
	(n, s) = map(int, input().split())
	levels = list(map(int, input().split()))
	if sum(levels) < s:
		print(-1)
	else:
		least = min(levels)
		for i in range(n):
			s -= levels[i] - least
			levels[i] = least
		if s <= 0:
			print(least)
		else:
			print(least - (s + n - 1) // n)


(n, s) = map(int, input().split())
k = list(map(int, input().split()))
sumk = sum(k)
mink = min(k)
if sumk < s:
	print(-1)
	exit()
if sumk - n * mink >= s:
	print(mink)
else:
	s -= sumk - n * mink
	if s % n == 0:
		print(mink - s // n)
	else:
		print(mink - s // n - 1)


(n, v) = map(int, input().split())
a = [int(el) for el in input().split()]
a.sort()
mm = 0
for i in range(n):
	mm += a[i] - a[0]
v = max(0, v - mm)
d = v // n
k = v % n
a[0] -= d
if k != 0:
	a[0] -= 1
if a[0] < 0:
	print(-1)
else:
	print(a[0])


def main():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) < s:
		return -1
	if len(set(a)) != 1:
		a.sort(reverse=True)
		q = a[-1]
		for i in range(n):
			s -= a[i] - q
		if s <= 0:
			return q
		if s % n == 0:
			return q - s // n
		return q - s // n - 1
	q = a[-1]
	if s % n == 0:
		return q - s // n
	return q - s // n - 1
print(main())


def ifPoss(arr, v, h):
	tot = 0
	for i in arr:
		tot += i - h
	return tot >= v

def prog():
	(n, v) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	minLev = -1
	(l, h) = (0, min(arr))
	while l <= h:
		m = int((l + h) / 2)
		if ifPoss(arr, v, m):
			minLev = max(minLev, m)
			l = m + 1
		else:
			h = m - 1
	return minLev
print(prog())


import math
(n, s) = map(int, input().split())
x = list(map(int, input().split()))
cur_min = min(x)
sum_x = sum(x)
ans = 0
if sum_x < s:
	print(-1)
else:
	ans = sum_x - n * cur_min
	if ans < s:
		cur_min -= math.ceil((s - ans) / n)
	print(cur_min)


import sys, os
import math
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
m = min(arr)
temp = s
arr.sort(reverse=True)
ans = 0
for i in range(n):
	if arr[i] > m:
		s -= arr[i] - m
if temp > sum(arr):
	print(-1)
elif s < 0:
	print(m)
else:
	print(m - (s + n - 1) // n)


(n, s) = map(int, input().split())
a = sorted(list(map(int, input().split())))
k = 0
mi = a[0]
for i in range(n):
	k += a[n - i - 1] - a[0]
	a[n - i - 1] -= a[n - i - 1] - a[0]
if k >= s:
	exit(print(a[0]))
elif sum(a) < s - k:
	exit(print(-1))
else:
	r = -(-(s - k) // n)
	print(a[0] - r)


(n, s) = map(int, input().split())
num = list(map(int, input().split()))
x = sum(num)
if x < s:
	print(-1)
else:
	k = min(num)
	for i in range(n):
		s -= abs(num[i] - k)
		num[i] = k
	if s <= 0:
		print(k)
	else:
		q = s // n
		k -= q
		if s % n == 0:
			print(k)
		else:
			print(k - 1)


(n, s) = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < s:
	print('-1')
else:
	l.sort()
	ans = 0
	val = l[0]
	check = 0
	for i in range(1, n):
		ans += l[i] - val
	if n == 1:
		print(l[0] - s)
	elif ans >= s:
		print(val)
	else:
		remain = s - ans
		we = remain // n
		if remain % n > 0:
			we += 1
		print(val - we)


(a, b) = map(int, input().split())
z = list(map(int, input().split()))
s = sum(z)
r = min(z)
if b > s:
	print(-1)
elif s - r * a >= b:
	print(r)
else:
	f = b - (s - r * a)
	print(r - f // a - (0 if f % a == 0 else 1))


import math
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
x = sum(v)
if s > x:
	print(-1)
else:
	a = min(v)
	if s < x - n * a:
		print(a)
	else:
		b = x - n * a
		c = s - b
		print(a - math.ceil(c / n))


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))

def fn(fin):
	sm = 0
	for v in a:
		if v >= fin:
			sm += v - fin
		else:
			return False
	return sm >= req
for _ in range(1):
	(n, req) = lst()
	a = lst()
	if sum(a) < req:
		print(-1)
		continue
	l = 0
	r = 10 ** 12 + 1
	while l <= r:
		mid = l + r >> 1
		if fn(mid):
			l = mid + 1
		else:
			r = mid - 1
	print(r)


import sys
input = sys.stdin.read()
(n, s, *a) = list(map(int, input.split()))
a.sort()
minimum = a[0]
sum1 = 0
for i in range(n):
	sum1 += a[i] - minimum
if s > sum1 + n * minimum:
	print(-1)
elif s <= sum1:
	print(minimum)
else:
	print((n * minimum - s + sum1) // n)


(n, s) = tuple(map(int, input().split()))
v = list(map(int, input().split()))
mn = min(v)
total = 0
possible = 0
for vi in v:
	possible += vi - mn
	total += vi
if total < s:
	print(-1)
elif possible >= s:
	print(mn)
else:
	remain = s - possible
	print(mn - (remain + n - 1) // n)


import os, sys, bisect
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')
input = lambda : sys.stdin.readline().strip()
imap = lambda : map(int, input().split())
ilist = lambda : list(imap())
mod = int(1000000000.0 + 7)
(n, s) = imap()
a = ilist()
sm = sum(a) - n * min(a)
if sm >= s:
	print(min(a))
else:
	rem = s - sm
	lvl = min(a) - (rem + n - 1) // n
	if lvl < 0:
		print(-1)
	else:
		print(lvl)


import sys

def solve(io):
	N = io.read_int()
	S = io.read_int()
	V = io.read_int_array(N)
	L = 0
	R = 1000000000
	good = -1
	while L <= R:
		M = (L + R) // 2
		if get_kvass(M, V) >= S:
			L = M + 1
			good = M
		else:
			R = M - 1
	io.println(min(good, *V))

def get_kvass(x, V):
	return sum([val - x for val in V if val > x])

class IO:
	in_stream = None
	out_stream = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, input_stream, output_stream):
		self.in_stream = input_stream
		self.out_stream = output_stream

	def read_to_buffer(self):
		self.raw = self.in_stream.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def read_string(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def read_int(self):
		return int(self.read_string())

	def read_float(self):
		return float(self.read_string())

	def read_string_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_string())
		return arr

	def read_int_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_int())
		return arr

	def read_float_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_float())
		return arr

	def read_line(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		if self.pos > 0:
			raise ValueError('Cannot call read_line in the middle of a line.')
		self.pos = len(self.buf)
		return self.raw

	def print(self, s):
		self.out_stream.write(str(s))

	def println(self, s):
		self.print(s)
		self.print('\n')

	def println_array(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flush_output(self):
		self.out_stream.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flush_output()


(n, s) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
if sum(l) < s:
	print(-1)
	exit()
cnt = 0
z = l[-1]
for i in range(n):
	if s == 0:
		break
	k = l[i] - z
	if s >= k:
		s -= k
	else:
		print(z)
		exit()
ka = s // n
ans = z - ka
if s % n == 0:
	print(ans)
else:
	print(ans - 1)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) < s:
	print('-1')
else:
	p = min(v)
	k = 0
	for i in v:
		if i > p:
			k += i - p
	if k >= s:
		print(p)
	else:
		x = s - k
		if x % n == 0:
			print(p - x // n)
		else:
			print(p - x // n - 1)


from math import ceil
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
V = sum(v)
m = min(v)
if V < s:
	answer = -1
else:
	v.sort(reverse=True)
	V_over = [0] * n
	V_over[0] = v[0] - m
	for i in range(1, n):
		V_over[i] = V_over[i - 1] + (v[i] - m)
	if V_over[-1] <= s:
		answer = m - ceil((s - V_over[-1]) / n)
	else:
		answer = m
print(answer)


(n, s) = list(map(int, input().split()))
v = [int(x) for x in input().split()]
t = sum(v)
if sum(v) < s:
	print(-1)
	return
b = min(v)
kol = t - b * n
s -= kol
if s <= 0:
	print(b)
	return
tmp = (s + n - 1) // n
print(b - tmp)


(n, s) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
S = sum(L)
mi = min(L)
equal = S - mi * n
if s > S:
	print(-1)
elif s <= equal:
	print(mi)
else:
	print(mi - (s - equal - 1) // n - 1)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
v.sort(key=lambda x: -x)
sm = 0
out = v[-1]
for i in range(n - 1):
	sm += v[i] - v[-1]
	out += v[i]
if out < s:
	print(-1)
	exit(0)
if sm >= s:
	print(v[-1])
	exit(0)
print(v[-1] - (s - sm - 1) // n - 1)


(n, m) = map(int, input().strip().split())
kegs = list(map(int, input().strip().split()))
import math
if sum(kegs) < m:
	print(-1)
else:
	import operator
	(index, value) = min(enumerate(kegs), key=operator.itemgetter(1))
	res = m
	for (i, k) in enumerate(kegs):
		if i != index:
			res -= k - value
	if res <= 0:
		print(value)
	else:
		print(value - math.ceil(res / n))


(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
sumx = sum(arr)
if sumx < s:
	print(-1)
else:
	minval = min(arr)
	diff1 = sumx - minval * n
	if diff1 >= s:
		print(minval)
	else:
		s -= diff1
		if s % n == 0:
			val = s // n
		else:
			val = s // n
			val += 1
		print(minval - val)


(n, s) = [int(x) for x in input().split()]
barrel = [int(x) for x in input().split()]
if sum(barrel) < s:
	print(-1)
else:
	print(min((sum(barrel) - s) // n, min(barrel)))


(n, s) = map(int, input().split())
kvas = list(map(int, input().split()))
if s > sum(kvas):
	print(-1)
elif s <= sum(kvas) - n * min(kvas):
	print(min(kvas))
else:
	print(min(kvas) - 1 - (s - sum(kvas) + n * min(kvas) - 1) // n)


(x, y) = map(int, input().split())
s = list(map(int, input().split()))
if sum(s) < y:
	print(-1)
else:
	j = sum(s) - y
	if j < x:
		print(0)
	elif x == j:
		print(1)
	else:
		print(min(min(s), j // x))


(n, s) = list(map(int, input().split()))
V = list(map(int, input().split()))
Sum = sum(V)
Min = min(V)
if Sum < s:
	print(-1)
elif Sum == s:
	print(0)
else:
	num = 0
	for i in range(0, n):
		num += V[i] - Min
	if num >= s:
		print(Min)
	else:
		temp = s - num
		ans = int(temp / n)
		if temp % n == 0:
			print(Min - ans)
		else:
			print(Min - ans - 1)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
x = l[0]
m = l[0]
for i in range(1, n):
	x += l[i]
	if l[i] < m:
		m = l[i]
if s > x:
	print(-1)
else:
	c = 0
	for i in range(n):
		if c >= s:
			break
		p = s - c
		c += min(p, l[i] - m)
	if c == s:
		print(m)
	else:
		p = s - c
		x = p // n
		y = p % n
		if y == 0:
			print(m - x)
		elif x == 0:
			print(m - 1)
		else:
			print(m - x - 1)


from math import ceil
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
ans = sum(l)
if n == 1 and s == l[0]:
	print(0)
	exit(0)
if ans < s:
	print(-1)
	exit(0)
minimal = min(l)
ans = 0
for i in range(len(l)):
	if l[i] > minimal:
		if ans + l[i] - minimal >= s:
			l[i] -= l[i] - minimal
			print(min(l))
			exit(0)
		ans += l[i] - minimal
		l[i] -= l[i] - minimal
print(max(l) - ceil((s - ans) / len(l)))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
k = min(a)
if s < m:
	print(-1)
else:
	p = s - m
	print(min(k, p // n))


import math
(n, s) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
arr = sorted(arr)
c = 0
for i in range(n):
	c += arr[i] - arr[0]
if c >= s:
	print(arr[0])
else:
	k = n
	z = math.ceil((s - c) / k)
	if z <= arr[0]:
		print(arr[0] - z)
	else:
		print(-1)


(n, s) = map(int, input().split())
ar = list(map(int, input().split()))
m = min(ar)
x = 0
for i in ar:
	x += i - m
if x >= s:
	print(m)
else:
	left = s - x
	print(max(m - ((left - 1) // n + 1), -1))


import math
import sys
input = sys.stdin.readline
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
(tot, mn) = (sum(v), min(v))
if tot < s:
	ans = -1
else:
	res = 0
	for i in range(n):
		if v[i] > mn:
			res += v[i] - mn
			v[i] -= mn
	if res >= s:
		ans = mn
	else:
		s -= res
		ans = mn - math.ceil(s / n)
print(ans)


import math
(n, s) = list(map(int, input().split()))
keg = list(map(int, input().split()))
keg.sort()
ans = -1
while s > 0:
	cmin = keg[0]
	if keg[0] < keg[-1]:
		for q in range(len(keg)):
			if s < 1:
				break
			if keg[q] > cmin:
				if s > keg[q] - cmin:
					s -= keg[q] - cmin
					keg[q] = cmin
				else:
					keg[q] -= s
					s = 0
	else:
		keg[0] -= math.ceil(s / len(keg))
		s = 0
if keg[0] < 0:
	print(-1)
else:
	print(keg[0])


(n, m) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
a_s = sum(l)
if a_s < m:
	print(-1)
else:
	l.sort(reverse=True)
	mins = l[n - 1]
	for i in range(n):
		m -= l[i] - mins
	if m <= 0:
		print(mins)
	else:
		print(mins - (m + n - 1) // n)


(n, s) = map(int, input().split())
x = list(map(int, input().split()))
m = -1
if sum(x) >= s:
	x = sorted(x, reverse=True)
	m = x[n - 1]
	for i in x:
		if s <= 0:
			break
		if i == m:
			import math
			m -= math.ceil(s / n)
			break
		else:
			s -= i - m
print(m)


ss = 0
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
(m, ss) = (min(v), sum(v))
if ss < s:
	print(-1)
else:
	print(min(m, (ss - s) // n))


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial
(n, s) = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))
(l, r) = (-1, min(values) + 1)
while r - l > 1:
	m = l + r >> 1
	cnt = 0
	for v in values:
		cnt += v - m
	if cnt >= s:
		l = m
	else:
		r = m
if l == -1:
	stdout.write('-1\n')
else:
	stdout.write(str(l) + '\n')


def inint():
	return int(input())

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

def main():
	(n, s) = inlist()
	a = inlist()
	sm = sum(a)
	if s > sm:
		print(-1)
		return
	lst = min(a)
	sm1 = sm - lst * n
	if s < sm1:
		print(lst)
	else:
		from math import ceil
		print(lst - ceil((s - sm1) / n))
main()


(N, S) = map(int, input().split())
aN = list(map(int, input().split()))
if (sum(aN) - S) / N < 0:
	print(-1)
else:
	print(min((sum(aN) - S) // N, min(aN)))


(n, s) = map(int, input().split())
A = list(map(int, input().split()))
mn = 1e+18
res = 0
for i in A:
	mn = min(i, mn)
	res += i
if res < s:
	print(-1)
elif s < res - mn * n:
	print(mn)
else:
	s = s - (res - mn * n)
	print(mn - (s + n - 1) // n)


import math
(m, n) = map(int, input().split())
li = sorted(list(map(int, input().split())))
l = li[0]
bli = []
if sum(li) < n:
	print(-1)
	exit()
for i in range(len(li)):
	bli.append(li[i] - li[0])
if sum(bli) >= n:
	print(l)
else:
	print(l - math.ceil((n - sum(bli)) / m))


from math import ceil
(n, s) = [int(no) for no in input().split()]
v = [int(no) for no in input().split()]
min_v = min(v)
current_available = sum([vi - min_v for vi in v])
if current_available >= s:
	print(min_v)
else:
	rem = s - current_available
	req = ceil(rem / n)
	if req <= min_v:
		print(min_v - req)
	else:
		print(-1)


import sys
input = sys.stdin.readline
(n, s) = map(int, input().split())
V = list(map(int, input().split()))
MIN = min(V)
SUM = sum(V)
if s > SUM:
	print(-1)
	sys.exit()
if SUM - MIN * n >= s:
	print(MIN)
	sys.exit()
print((SUM - s) // n)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
m = min(v)
if s > sum(v):
	print('-1')
	exit()
v = sorted(v)
total = 0
for i in v:
	total += i - m
if total >= s:
	print(m)
else:
	print((sum(v) - s) // n)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
su = sum(l)
if su < m:
	print(-1)
else:
	c = (su - m) // n
	print(min(min(l), c))


(n, s) = map(int, input().split())
v = sorted(list(map(int, input().split())))
if sum(v) < s:
	print(-1)
else:
	s0 = sum(v) - v[0] * n
	if s <= s0:
		print(v[0])
	else:
		s -= s0
		if s % n == 0:
			print(v[0] - s // n)
		else:
			print(v[0] - s // n - 1)


n = input().split(' ')
data = [int(i) for i in input().split(' ')]
s = sum(data)
if s < int(n[1]):
	s = -1
else:
	s -= int(n[1])
	s //= int(n[0])
if min(data) < s:
	s = min(data)
print(s)


import sys
from math import ceil
(n, s) = [int(val) for val in input().split()]
a = [int(val) for val in input().split()]
total = sum(a)
if total < s:
	print('-1')
else:
	summ = 0
	smallest = min(a)
	for i in a:
		summ += abs(smallest - i)
	if summ >= s:
		pass
	else:
		diff = s - summ
		pours = int(ceil(float(diff) / float(n)))
		smallest -= pours
	print(smallest)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 10 ** 9 + 7

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	large.reverse()
	small.extend(large)
	return small

def count(n):
	return n * (n + 1) // 2

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

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

def input():
	return sys.stdin.readline().strip()
(n, s) = get_ints()
Arr = get_array()
total = sum(Arr)
if total < s:
	print(-1)
	exit()
left = 0
mini = min(Arr)
for i in range(n):
	left += Arr[i] - mini
if left >= s:
	print(mini)
	exit()
else:
	s = s - left
	think = mini - s // n
	if s % n != 0:
		think -= 1
	print(think)


(n, s) = list(map(int, input().split()))
v = list(map(int, input().split()))
total_kvass = sum(v)
if total_kvass < s:
	print(-1)
	exit(0)
r = min((total_kvass - s) // n, sorted(v)[0])
print(r)


(n, s) = map(int, input().split())
ls = list(map(int, input().split()))
m = sum(ls) - min(ls) * n
if s <= m:
	print(min(ls))
elif s > sum(ls):
	print('-1')
else:
	print((sum(ls) - s) // n)


n = list(map(int, input().split()))
s = n[1]
n = n[0]
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
k = min(a)
su = 0
if s > sum(a):
	print(-1)
else:
	for i in range(len(a)):
		if a[i] > k:
			su += a[i] - k
			a[i] = k
			if su >= s:
				break
	if su < s:
		k = (n * k - (s - su)) // n
		print(k)
	else:
		print(k)


(n, left) = map(int, input().split())
arr = list(map(int, input().split()))
if sum(arr) < left:
	print(-1)
else:
	mn = min(arr)
	extra = 0
	for v in arr:
		extra += v - mn
	if extra >= left:
		print(mn)
	else:
		left -= extra
		stages = left // n
		if left % n != 0:
			stages += 1
		print(mn - stages)


from sys import stdin, stdout
input = stdin.readline
rstr = lambda : input().strip()
rstrs = lambda : [str(x) for x in input().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint = lambda : int(input())
rints = lambda : [int(x) for x in input().split()]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
(n, s) = rints()
a = rints()
if sum(a) < s:
	print(-1)
else:
	(mi, diff) = (min(a), 0)
	for i in a:
		diff += i - mi
	s -= diff
	if s <= 0:
		print(mi)
	else:
		print((mi * n - s) // n)


from math import ceil
(n, s) = map(int, input().strip().split())
v = list(map(int, input().strip().split()))
if s > sum(v):
	print(-1)
elif s == sum(v):
	print(0)
else:
	m = min(v)
	total_min = m * n
	diff = sum(v) - total_min
	if diff >= s:
		print(m)
	else:
		d = ceil((s - diff) / n)
		print(m - d)


(no_of_glass, kvass_needed) = map(int, input().split())
volume = list(map(int, input().split()))
volume.sort()
temp = list(volume)
kvass_filled = 0
flag = 0
for i in range(1, no_of_glass):
	sub = volume[i] - volume[0]
	if kvass_filled >= kvass_needed:
		flag = 1
		break
	if kvass_filled + sub > kvass_needed:
		sub = kvass_needed - kvass_filled
	volume[i] = volume[i] - sub
	kvass_filled += sub
if sum(temp) < kvass_needed:
	print(-1)
elif flag == 1:
	print(volume[0])
else:
	sub = (kvass_needed - kvass_filled) // no_of_glass
	add = (kvass_needed - kvass_filled) % no_of_glass
	if add > 0:
		add = 1
	volume[0] = volume[0] - sub - add
	if volume[0] <= 0:
		print(0)
	else:
		print(volume[0])


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict

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

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

def Neo():
	return list(map(int, sys.stdin.readline().split()))
(n, s) = neo()
A = Neo()
m = min(A)
if sum(A) < s:
	print(-1)
	exit()
for i in range(n):
	s -= A[i] - m
if s <= 0:
	print(m)
else:
	t = math.ceil(s / n)
	print(m - t)


first = input()
first = first.split(' ')
second = input()
second = second.split(' ')
n = int(first[0])
s = int(first[1])
v = []
for p in second:
	v.append(int(p))
if sum(v) < s:
	print(-1)
elif sum(v) == s:
	print(0)
else:
	min_volume = min(v)
	sum = 0
	v_ = []
	for each in v:
		sum += each - min_volume
		v_.append(min_volume)
	if sum >= s:
		print(min_volume)
	else:
		s = s - sum
		volume_r = s / n
		if s % n != 0:
			volume_r += 1
		print(min_volume - int(volume_r))


(n, s) = map(int, input().split())
tab = sorted([int(x) for x in input().split()])
best = -1
if sum(tab) >= s:
	s -= sum(tab) - tab[0] * len(tab)
	best = min(tab[0], tab[0] - (s + len(tab) - 1) // len(tab))
print(best)


(N, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) < s:
	print(-1)
else:
	mi = min(v)
	num = 0
	for i in range(N):
		num += v[i] - mi
		v[i] -= v[i] - mi
	if s - num <= 0:
		print(mi)
	else:
		m = (s - num) // N + int((s - num) % N != 0)
		print(mi - m)


def solve():
	(n, s) = map(int, input().split())
	v = list(map(int, input().split()))
	sv = sum(v)
	if sv < s:
		print(-1)
		return
	mnf = min(v)
	top = 0
	for x in v:
		top += max(0, x - mnf)
	if top >= s:
		print(mnf)
		return
	s -= top
	mnf -= s // n
	s %= n
	if s > 0:
		mnf -= 1
	print(mnf)
solve()


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
mini = min(a)
sumi = 0
for i in range(n):
	sumi += abs(a[i] - mini)
if s <= sumi:
	print(mini)
elif sumi + n * mini >= s:
	rest = s - sumi
	if rest % n == 0:
		part = rest // n
		print(mini - part)
	else:
		part = rest // n
		print(mini - part - 1)
else:
	print('-1')


from math import *

def solve():
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	answer = sum(l)
	if n == 1 and s == l[0]:
		return 0
	if answer < s:
		return -1
	minn = min(l)
	answer = 0
	for i in range(len(l)):
		if l[i] > minn:
			if answer + l[i] - minn >= s:
				l[i] -= l[i] - minn
				return min(l)
			answer += l[i] - minn
			l[i] -= l[i] - minn
	ch = max(l)
	ll = len(l)
	p = ceil((s - answer) / len(l))
	return ch - p
print(solve())


import math
(n, s) = map(int, input().split())
v = input().split()
mini = math.inf
for i in range(n):
	mini = min(int(v[i]), mini)
s += mini * n
for i in range(n):
	s -= int(v[i])
if s < 0:
	print(mini)
elif s > mini * n:
	print(-1)
elif s % n == 0:
	print(mini - s // n)
else:
	print(mini - s // n - 1)


import sys
input = sys.stdin.readline
from collections import *

def judge(x):
	s2 = sum((vi - x for vi in v))
	return s2 >= s

def binary_search():
	(l, r) = (0, min(v))
	while l <= r:
		m = (l + r) // 2
		if judge(m):
			l = m + 1
		else:
			r = m - 1
	return r
(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) < s:
	print(-1)
	exit()
print(binary_search())


[n, s] = [int(x) for x in input().split(' ')]
v = [int(x) for x in input().split(' ')]
v.sort()
minV = v[0]
totalV = sum(v)
if totalV < s:
	print(-1)
elif totalV - minV * n >= s:
	print(minV)
else:
	remain = totalV - s
	print(remain // n)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

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

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
(n, s) = map(int, input().split())
v = sorted(list(map(int, input().split())), reverse=True)
if sum(v) < s:
	print(-1)
elif sum(v) == s:
	print(0)
else:
	mn = min(v)
	ch = 0
	for i in range(n - 1):
		s -= v[i] - mn
		if s <= 0:
			ch = 1
			break
	if ch:
		print(mn)
	else:
		temp = math.ceil(s / n)
		print(mn - temp)


from math import ceil
(n, s) = [int(x) for x in input().split()]
lst = [int(x) for x in input().split()]
tot = sum(lst)
if s > tot:
	print(-1)
	exit()
elif s == tot:
	print(0)
	exit()
s -= tot - min(lst) * n
if s <= 0:
	print(min(lst))
	exit()
else:
	x = min(lst)
	if s <= n:
		print(x - 1)
	elif s // n == s / n:
		print(x - s // n)
	else:
		print(x - ceil(s / n))


import math

def main():
	(n, s) = map(int, input().split())
	volume = list(map(int, input().split()))
	if s > sum(volume):
		print(-1)
		return
	min_val = min(volume)
	for i in range(n):
		diff = volume[i] - min_val
		if s >= diff:
			volume[i] = min_val
			s -= diff
		else:
			volume[i] -= s
			s = 0
		if s == 0:
			break
	if s > 0:
		remove1 = s // n
		remove2 = s % n
		print(min_val - remove1 - math.ceil(remove2 / n))
	else:
		print(min_val)
main()


(n, size) = list(map(int, input().split()))
array = list(map(int, input().split()))
if sum(array) - size < 0:
	print(-1)
else:
	print(min(min(array), (sum(array) - size) // n))


import sys
(n, s) = [int(s) for s in input().split()]
array = [int(s) for s in input().split()]
sorted_array = sorted(array)
min_ = sorted_array[0]
if sum(array) < s:
	print(-1)
	sys.exit(0)
if sum(array) == s:
	print(0)
	sys.exit(0)
if sum(array) - n * min_ >= s:
	print(min_)
else:
	print(min_ - ((s - (sum(array) - n * min_)) // n + int((s - (sum(array) - n * min_)) % n > 0)))


(n, s) = map(int, input().split())
arr = [int(x) for x in input().split()]

def get_extra(mn):
	global arr, s
	ret = 0
	for x in arr:
		if x > mn:
			ret += x - mn
	if ret >= s:
		return True
	else:
		return False
if sum(arr) < s:
	print('-1')
	exit()
start = 0
end = min(arr)
i = 50
while start <= end:
	i = i - 1
	if i == 0:
		break
	mid = (start + end) // 2
	if get_extra(mid):
		start = mid
	else:
		end = mid - 1
if get_extra(end):
	print(end)
elif get_extra(mid):
	print(mid)
elif get_extra(start):
	print(start)
else:
	print('-1')


(n, s) = map(int, input().split())
l = list(map(int, input().split()))
sa = sum(l)
sa -= s
if sa < 0:
	print(-1)
else:
	sa //= n
	if min(l) < sa:
		print(min(l))
	else:
		print(sa)


(n, s) = map(int, input().split())
v = [int(i) for i in input().split()]
minVol = min(v)
sumVol = 0
for i in range(0, n):
	sumVol = sumVol + v[i]
if sumVol < s:
	print(-1)
elif sumVol == s:
	print(0)
else:
	kvas = 0
	for i in range(n):
		if v[i] > minVol:
			kvas = kvas + v[i] - minVol
			v[i] = v[i] - (v[i] - minVol)
	if kvas >= s:
		print(minVol)
	else:
		diff = s - kvas
		if diff % n == 0:
			print(v[0] - diff // n)
		else:
			print(v[0] - diff // n - 1)


import sys
line = sys.stdin.readline().strip().split()
n = int(line[0])
s = int(line[1])
ksum = 0
kmin = 10 ** 9 + 1
line = sys.stdin.readline().strip().split()
for i in range(0, n):
	v = int(line[i])
	ksum = ksum + v
	kmin = min(kmin, v)
if ksum < s:
	print(-1)
else:
	print(min(kmin, (ksum - s) // n))


(n, s) = [int(w) for w in input().split()]
v = [int(w) for w in input().split()]
r = sum(v) - s
if r < 0:
	print(-1)
else:
	print(min(r // n, *v))


(n, s) = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]
total = sum(data)
diff = total - s
if diff < 0:
	print(-1)
else:
	print(min(diff // n, min(data)))


arr = list(map(int, input().strip().split(' ')))
n = arr[0]
s = arr[1]
ss = 0
arr = list(map(int, input().strip().split(' ')))
ss = sum(arr)
if ss < s:
	print(-1)
else:
	ss = 0
	arr.sort()
	for i in range(n):
		ss += arr[i] - arr[0]
	if ss > s:
		print(arr[0])
	else:
		t = arr[0] - (s - ss + n - 1) // n
		print(t)


import sys
import math
r = lambda : sys.stdin.readline()
(n, s) = map(int, r().split())
arr = list(map(int, input().split()))
cavas = 0
min_arr = min(arr)
sum_arr = 0
for i in range(n):
	sum_arr += arr[i]
	cavas += arr[i] - min_arr
if s > sum_arr:
	print(-1)
elif cavas >= s:
	print(min_arr)
else:
	dd = (s - cavas) / n
	dd = math.ceil(dd)
	print(min_arr - dd)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
summa = sum(l)
need = 0
if summa < b:
	print(-1)
elif summa == b:
	print(0)
else:
	need = summa - b
	print(min(min(l), need // a))


(n, s) = map(int, input().strip().split())
v = list(map(int, input().strip().split()))
v.sort()
izd = 0
if sum(v) < s:
	print(-1)
else:
	for i in range(len(v)):
		izd += v[i] - v[0]
	if izd >= s:
		print(v[0])
	else:
		x = (s - izd) / n
		if int(x) == x:
			print(v[0] - int(x))
		else:
			print(v[0] - int(x) - 1)


import math
(n, c) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
if s < c:
	print(-1)
	exit(0)
r = 0
m = min(a)
for i in a:
	r += i - m
if r >= c:
	print(m)
else:
	print(m - math.ceil((c - r) / n))


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) < s:
	print('-1')
else:
	m = min(v)
	v.sort(reverse=True)
	for i in range(n):
		diff = v[i] - m
		diff = min(diff, s)
		v[i] -= diff
		s -= diff
		if s == 0:
			break
	q = s // n
	for i in range(n):
		v[i] -= q
		s -= q
	if s > 0:
		print(min(v) - 1)
	else:
		print(min(v))


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
mn = min(a)
if sum(a) < s:
	print(-1)
else:
	print(min(mn, (sum(a) - s) // n))


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
(suma, mina) = (sum(a), min(a))
if suma < s:
	print(-1)
else:
	print(min((suma - s) // n, mina))


import math
from decimal import Decimal
import heapq

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

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

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

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

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

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

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < s:
	print(-1)
	exit()
d = min(a)
tc = 0
for i in a:
	tc += i - d
if tc >= s:
	print(d)
else:
	tc = s - tc
	if tc % n == 0:
		print(d - tc // n)
	else:
		print(d - tc // n - 1)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < s:
	print(-1)
else:
	x = 0
	m = min(a)
	for i in range(n):
		x += a[i] - m
	if s <= x:
		print(m)
	else:
		d = s - x
		y = d // n
		r = d % n
		if r != 0:
			y += 1
		print(m - y)


(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
sno = arr[0]
for i in range(0, len(arr)):
	if arr[i] < sno:
		sno = arr[i]
for i in range(0, len(arr)):
	if arr[i] - sno < s:
		s -= arr[i] - sno
		arr[i] = sno
	else:
		print(sno)
		exit()
if s == 0:
	print(sno)
	exit()
while s > 0:
	if s > 1000 * n:
		s -= 1000 * n
		sno -= 1000
	elif s > 100 * n:
		s -= 100 * n
		sno -= 100
	elif s > 10 * n:
		s -= 10 * n
		sno -= 10
	elif s > 0:
		s -= n
		sno -= 1
	if sno < 0:
		print('-1')
		exit()
print(sno)


import math
(n, s) = map(int, input().split())
a = [int(s) for s in input().split()]
a.sort()
if sum(a) < s:
	print(-1)
else:
	sum = 0
	for i in range(n - 1, 0, -1):
		sum += a[i] - a[0]
	if sum >= s:
		print(a[0])
	else:
		print(a[0] - math.ceil((s - sum) / n))


(n, s) = map(int, input().split())
arr = [int(x) for x in input().split()]
arr.sort(reverse=True)
flag = 0
for i in range(n - 1):
	s -= min(s, arr[i] - arr[-1])
	if s != 0:
		arr[i] = arr[-1]
	if s == 0:
		flag = 1
		break
if flag == 1:
	print(arr[-1])
else:
	arr[-1] -= s // n
	if s % n != 0:
		arr[-1] -= 1
	if arr[-1] >= 0:
		print(arr[-1])
	else:
		print(-1)


(n, S) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

def ans():
	global S
	to_min = sum(A) - n * min(A)
	S -= to_min
	if S <= 0:
		return min(A)
	if n * min(A) < S:
		return -1
	return (n * min(A) - S) // n
print(ans())


I = lambda : map(int, input().split())
(n, s) = I()
V = list(I())
V_min = min(V)
V = sum(V)
print(-1 if V < s else min(V_min, (V - s) // n))


import math
(n, s) = map(int, input().split())
kegs = [int(k) for k in input().split()]
if s > sum(kegs):
	print(-1)
	exit()
opsleft = s
minimum = min(kegs)
amtleft = 0
for keg in kegs:
	amtleft += keg - minimum
if s <= amtleft:
	print(minimum)
else:
	res = minimum - math.ceil((s - amtleft) / n)
	print(res)


import sys
import bisect
import math

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

def in1():
	return int(input())
(n, s) = get_line()
a = get_line()
t1 = min(a)
c = 0
for i in range(n):
	c += a[i] - t1
if c >= s:
	print(t1)
else:
	t2 = (s - c) // n
	if (s - c) % n == 0 and t2 <= t1:
		print(t1 - t2)
	elif (s - c) % n != 0 and t2 + 1 <= t1:
		print(t1 - (t2 + 1))
	else:
		print(-1)


from math import ceil
[n, K] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
S = sum(a)
m = min(a)
P = S - n * m
if K > S:
	print(-1)
elif K <= P:
	print(m)
else:
	K = K - P
	d = int(ceil(K / n))
	print(m - d)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
mn = min(v)
sm = cnt = 0
for i in range(n):
	sm += v[i]
	cnt += v[i] - mn
if sm < s:
	print(-1)
elif s <= cnt:
	print(mn)
else:
	print(mn - (s - cnt) // n - min(1, (s - cnt) % n))


(n, s) = input().split()
n = int(n)
s = int(s)
l = input().split()
l = list(map(int, l))
x = sum(l)
m = min(l)
h = len(l)
if x < s:
	print(-1)
elif m * h <= x - s:
	print(m)
else:
	q = (m * h - (x - s)) / h
	if int(q) == q:
		print(m - int(q))
	else:
		print(m - (int(q) + 1))


(n, s) = map(int, input().split())
l = [int(i) for i in input().split()]
if sum(l) < s:
	print(-1)
else:
	print(min([(sum(l) - s) // n, min(l)]))


def foo(s, v):
	n = len(v)
	if sum(v) < s:
		return -1
	mini = min(v)
	for i in range(n):
		s -= v[i] - mini
		if s <= 0:
			return mini
	k = s // n
	s -= n * k
	mini -= k
	while s > 0:
		s -= n
		mini -= 1
	return mini
(n, s) = list(map(int, input().strip().split(' ')))
v = list(map(int, input().strip().split(' ')))
print(foo(s, v))


from math import ceil
(n, req) = map(int, input().split())
ar = [int(x) for x in input().split()]
given = 0
minn = min(ar)
for k in range(n):
	given += ar[k] - minn
if req - given > n * minn:
	print(-1)
elif req - given <= 0:
	print(minn)
else:
	print(minn - ceil((req - given) / n))


import math
(n, s) = map(int, input().split())
result = [int(i) for i in input().split()]
result.sort(reverse=True)
tot = sum(result)
if tot < s:
	print(-1)
elif tot == s:
	print(0)
else:
	x = tot - result[-1] * n
	a = n * result[-1]
	if s <= x:
		print(result[-1])
	else:
		p = s - x
		a = math.ceil(p / n)
		print(result[-1] - a)


import math
(n, k) = map(int, input().strip().split(' '))
lst = list(map(int, input().strip().split(' ')))
s = sum(lst)
if s < k:
	print(-1)
else:
	c = 0
	m = min(lst)
	for i in range(n):
		c += lst[i] - m
		lst[i] = m
	if c >= k:
		print(m)
	else:
		k -= c
		c1 = k % n
		if c1 == 0:
			print(m - k // n)
		else:
			print(m - k // n - 1)


(n, s) = map(int, input().split())
mas = list(map(int, input().split()))
m = min(mas)
(e, q) = (0, 0)
for (i, x) in enumerate(mas):
	e += x - m
	q += x
if s > q:
	print(-1)
elif e >= s:
	print(m)
else:
	a = s - e
	(b, c) = (a // n, a % n)
	if c > 0:
		b += 1
	print(m - b)


(n, s) = [int(x) for x in input().split(' ')]
v = [int(x) for x in input().split(' ')]
if sum(v) < s:
	ans = -1
else:
	ans = min(min(v), (sum(v) - s) // n)
print(ans)


def main():
	(n, s) = map(int, input().split())
	v = list(map(int, input().split()))
	minn = min(v)
	summ = 0
	alll = 0
	for el in v:
		alll += el
	if alll < s:
		print(-1)
		return
	for i in range(n):
		summ += v[i] - minn
	s -= summ
	if s < 0:
		print(minn)
		return
	else:
		k = s // n
		if s % n > 0:
			k += 1
		print(minn - k)
		return
main()


R = lambda : map(int, input().split())
(n, m) = R()
L = list(R())
if sum(L) < m:
	print(-1)
else:
	mi = min(L)
	for i in range(n):
		if m > 0:
			m -= L[i] - mi
		else:
			break
	if m <= 0:
		print(mi)
	else:
		print(mi - (m + n - 1) // n)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
print(-1 if sum(a) < m else min(min(a), (sum(a) - m) // n))


(n, s) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
sum = 0
for i in a:
	sum += i
if sum < s:
	print(-1)
	exit(0)
a.sort()
for i in range(len(a)):
	c = min(s, max(0, a[n - i - 1] - a[0]))
	s -= c
	a[n - i - 1] -= c
if s <= 0:
	a.sort()
	print(a[0])
else:
	print(a[0] - (s + n - 1) // n)


(n, s) = list(map(int, input().split()))
a = list(map(int, input().split()))
p = sum(a)
m = min(a)
if s > p:
	print(-1)
elif p == s:
	print(0)
elif s <= p - n * m:
	print(m)
else:
	s = s - (p - n * m)
	p = n * m
	p = p - s
	print(p // n)


def mynfn():
	x = input().split(' ')
	n = int(x[0])
	s = int(x[1])
	y = input().split(' ')
	min = 1000000000000
	sum = 0
	k = 0
	for i in range(len(y)):
		y[i] = int(y[i])
		if y[i] < min:
			min = y[i]
			k = i
		sum = sum + y[i]
	if sum < s:
		print('-1')
	else:
		a = sum - min * n
		if a >= s:
			print(min)
		else:
			h1 = int((s - a) / n)
			h2 = (s - a) % n
			if h2 == 0:
				print(min - h1)
			else:
				print(min - h1 - 1)
mynfn()


arr = []
cap = 0

def chck(k):
	ans = 0
	for i in arr:
		if i < k:
			return False
		ans = ans + i - k
	if ans >= cap:
		return True
	return False

def bsrch(strt, ed):
	ans = -1
	while strt <= ed:
		mid = (strt + ed) // 2
		if chck(mid):
			ans = mid
			strt = mid + 1
		else:
			ed = mid - 1
	return ans
(n, cap) = input().split()
n = int(n)
cap = int(cap)
arr = list(map(int, input().split()))
print(bsrch(0, 1000000000))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
m = min(l)
s = sum(l)
if sum(l) < k:
	print(-1)
elif s - m * n >= k:
	print(m)
else:
	val = s - m * n
	k -= val
	print(m - (k // n + int(k % n != 0)))


TN = 1

def solution():
	from math import ceil
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	if s > sum(a):
		ans = -1
	else:
		v = min(a)
		for i in range(n):
			s -= a[i] - v
		if s <= 0:
			ans = v
		else:
			ans = ceil(v - (s + n - 1) / n)
	print(ans)
while TN != 0:
	solution()
	TN -= 1


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
if s > sum(v):
	print(-1)
	exit(0)
v.sort()
m = v[0]
for i in range(len(v)):
	s -= v[i] - m
if s <= 0:
	print(m)
	exit(0)
m -= (s + n - 1) // n
print(m)


(n, s) = list(map(int, input().split()))
cl = list(map(int, input().split()))
cl = sorted(cl)
mn = cl[0]
sm = sum(cl)
if sm < s:
	print(-1)
else:
	t = s - (sm - n * mn)
	if t <= 0:
		print(mn)
	else:
		k = (t - 1) // n + 1
		print(mn - k)


(n, s) = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
v = sorted(v)
sv = sum(v)
if s > sv:
	print(-1)
else:
	for i in v:
		s -= i - v[0]
	if s <= 0:
		print(v[0])
	else:
		print((n * v[0] - s) // n)


def solve():
	rd = lambda : list(map(int, input().split()))
	(n, s) = rd()
	arr = rd()
	k = sum(arr)
	if s > k:
		print(-1)
		return
	if s == k:
		print(0)
		return
	arr.sort(reverse=True)
	mi = arr[-1]
	tmp = 0
	for item in arr:
		tmp += item - mi
	if tmp >= s:
		print(mi)
	else:
		tmp = s - tmp
		l = len(arr)
		mi -= int(tmp / l)
		tmp -= int(tmp / l) * l
		if tmp > 0 and tmp % l != 0:
			mi -= 1
		if mi >= 0:
			print(mi)
		else:
			print(-1)
solve()


import sys, math
(n, s) = map(int, input().split())
a = [int(x) for x in input().split()]
if sum(a) < s:
	print(-1)
else:
	m = min(a)
	free = 0
	for i in range(n):
		free += a[i] - m
		a[i] -= m
	if free >= s:
		print(m)
		sys.exit()
	s -= free
	print(m - math.ceil(s / n))