#include <iostream>
#include <algorithm>
#include <vector>
#define FAST_IO() \
{\
ios::sync_with_stdio(false);\
cin.tie(NULL); \
cout.tie(NULL); \
}\
using namespace std;
int main()
{
FAST_IO();
int n, m;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> v[i];
sort(v.begin(), v.end());
cin >> m;
int s = 0, e = v[n - 1];
int res = 0;
while (s <= e)
{
int sum = 0;
int mid = (s + e) / 2;
for (int i = 0; i < n; i++)
sum += min(v[i], mid);
if (m >= sum)
{
res = mid;
s = mid + 1;
}
else
e = mid - 1;
}
cout << res;
return 0;
}