#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i, a, b) for(__typeof(b) i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for(__typeof(a) i = a, _b = b; i >= _b; --i)
#define ALL(a) (a).begin(), (a).end()
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define dq deque<int>
#define nend '\n'
using namespace std;
const ll hashi=2e9+11;
ll add(ll a, ll b) {
return (a+b)%hashi;
}
ll sub(ll a, ll b) {
return ((a-b)%hashi+hashi)%hashi;
}
ll mul(ll a, ll b) {
return (a*b)%hashi;
}
const ll inf=1e18;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const int N=2e5+3;
int n;
vector<ll> b;
vector<ll> pre;
ll S;
bool feasible(ll x) {
int idx = lower_bound(ALL(b), x) - b.begin();
ll cnt = idx;
ll sum = pre[idx];
ll B = x*cnt - sum;
return B + (ll)n*x <= S;
}
int main() {
fast;
cin >> n;
b.resize(n);
FOR(i,0,n-1) cin >> b[i];
sort(ALL(b));
pre.assign(n+1, 0);
FOR(i,0,n-1) pre[i+1] = pre[i] + b[i];
S = pre[n];
ll l = 0, r = b[n-1];
ll ans = 0;
while (l<=r) {
ll mid=l+(hi-l)>>1;
if (feasible(mid)) {
ans = mid;
l = mid+1;
} else {
r = mid-1;
}
}
cout << ans << nend;
return 0;
}