https://www.acmicpc.net/problem/2512
n=int(input())
arr=[0]*n
st=list(map(int,input().split()))
for i in range(n):
arr[i]=st[i]
max=int(input())
arr.sort()
left=0
right=arr[n-1]
while left<=right:
mid=(left+right)//2
now=0
for i in range(n):
if mid>=arr[i]: now+=arr[i]
else: now+=mid
if now>max: right=mid-1
else: left=mid+1
print(right)