#include <bits/stdc++.h>          
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll POW(ll x, ll n) {
    if (n==0) return 1;
    if (n%2) return x * POW(x,n-1);
    ll res = POW(x,n/2);
    return res * res;
}

int main() {
    ll N; cin >> N;
    ll ans = inf;
    for (ll b=0; b<=60; b++) {
        ll x = POW(2,b);
        ll a = N/x, c = N%x;
        ll res = a + b + c;
        chmin(ans,res);
    }

    cout << ans << endl;
}
#include<bits/stdc++.h>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define task "nondec"
#define pii pair<pll, ll>
using namespace std;
using ll = long long;
const int  N = 1e5+5;
const ll mod = 1e9 + 7;
const ll base = 350;
const ll cs = 331;
const long double Exp = 1e-7;
ll m, n, t, k, tong, ans, b[N], fe[N], c[N], d[N];
long double a[N];
vector<ll> adj[N];
vector<ll> kq;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
void add(ll& x, ll y)
{
    x += y;
    if(x >= mod)x -= mod;
}
long double f(long double x)
{
    long double res = 0;
    for(int i = 1; i <= n; i ++)res += x + a[i] - min(x*2,a[i]);
    return res * 1.0 / n;
}
void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    sort(a+1, a+1+n);
    ll lf = 1, rt = n, mid;
    while(lf <= rt)
    {
        mid = (lf + rt) / 2;
        if(mid < n && f(a[mid] /2.0) > f(a[mid+1] / 2.0))lf = mid + 1;
        else rt = mid - 1;
    }
    cout << fixed << setprecision(9) << f(a[lf] / 2.0);

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".in", "r"))
    {
        freopen(task".in", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
4 3
3 2 1 1
2
1 2
3 4
*/
