n = int(input())
asset = list(map(int,input().split()))
chongAsset = int(input())
start,end = 0,max(asset)
result = []
while start<=end:
mid =(start+end)//2
total =0
for x in asset:
if x<mid:
total+=x
else :
total+=mid
if total<=chongAsset:
start = mid + 1
else :
end = mid - 1
print(end)
total에 예산을 조건에 따라 더해나가며 이분탐색을 진행하는 알고리즘이다.