#include <bits/stdc++.h>

#define iter_all(x) x.begin(), c.end()
#define umap unordered_map
#define uset unordered_set

using namespace std;

typedef long long int ll;

auto io_speed = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    return 0;
}();

ll pow_mod(ll a, ll e, ll mod) {
    ll res = 1;
    while(e) {
        if(e&1) res = res * a%mod;
        e>>=1;
        a=a*a%mod;
    }
    return res;
}

ll inv_mod(ll b, ll m) {
    ll a=m, x=0, y=1, r, q;
    while(b) {
        r = a%b;
        q = a/b;
        a = b;
        b = r;
        r = x;
        x = y;
        y = r-q*y;
    }
    x+=m;
    return x%m;
}

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}

ll rec(ll x, ll y, map<ll, ll> &dp) {
    auto itr = dp.find(y);
    if(itr == dp.end()) {
        if(y <= x) dp[y] = x-y;
        else {
            ll res = y-x;
            if(y&1) {
                res = min(res, rec(x, y+1, dp) + 1);
                res = min(res, rec(x, y-1, dp) + 1);
            } else {
                res = min(res, rec(x, y>>1, dp) + 1);
            }
            dp[y] = res;
        }
    }
    return dp[y];
}

void solve() {
    ll x, y;
    cin >> x >> y;
    map<ll, ll> dp;
    cout << rec(x, y, dp) << endl;
}

int main() {
    int t = 1;
    // cin >> t;
    for(int i = 1; i <=t; i++) {
        // cout << "Case #"<<i<<": ";
        solve();
    }
}

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007 
#define INF 10000000000000000
#define ff first
#define ss second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.141592653589793238462643383279
#define PYES cout<<"YES"<<endl
#define PNO cout<<"NO"<<endl
#define SB(a) sort(a.begin(),a.end(),greater<ll>());
#define SS(a) sort(a.begin(),a.end());
#define vll vector<ll>
#define vpll vector<pll>
vector<bool> prime;
vector<ll> fact,inv,primes,factors,pf;
void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
void factorize(ll a)
{
	factors.clear();
	for(ll i=1;i*i<=a;i++)
	{
		if (i*i==a) factors.pb(i);
		else if (a%i==0)
		{
			factors.pb(i);
			factors.pb(a/i);
		}
	}
	sort(factors.begin(),factors.end());
}
ll power(ll a,ll b)
{
	if(a==1||b==0)	return 1;
	ll c=power(a,b/2);
	ll res=1;
	res=c*c;
	if(res>=mod)	res%=mod;
	if(b%2)	res*=a;
	if(res>=mod)	res%=mod;
	return res;
}
ll modInv(int a)
{
	return power(a,mod-2);
}
void factorial(ll n)
{
	fact.resize(n+1);
	fact[0]=1;
	for(ll i=1;i<=n;i++)
	{
		fact[i]=fact[i-1]*i;
		if(fact[i]>=mod)	fact[i]%=mod;
	}
}
void InvFactorial(ll n)
{
	inv.resize(n+1);
	inv[0]=1;
	for(ll i=1;i<=n;i++)	inv[i]=modInv(fact[i]);
}
ll ncr(ll n,ll r)
{
	if(n<r||n<0||r<0)	return 0;
	ll b=inv[n-r];
	ll c=inv[r];
	ll a=fact[n]*b;
	if(a>=mod)	a%=mod;
	a*=c;
	if(a>=mod)	a%=mod;
	return a;
}
void remove_duplicates(vpll &v)
{
	sort(v.begin(),v.end());
	ll _size=unique(v.begin(),v.end())-v.begin();
	v.resize(_size);
}
unsigned ll gcd(unsigned ll u, unsigned ll v)
{
    if(u==0||v==0) return max(u,v);
    unsigned ll shift=__builtin_ctz(u|v);
	u>>=__builtin_ctz(u);
    do{
    	v>>=__builtin_ctz(v);
    	if(u>v)	swap(u,v);
    	v-=u;
    }while(v!=0);
    return u<<shift;
}
void sieve(ll n)
{
    prime.assign(n+1,1);
	prime[1]=false;
    for(ll p=2;p*p<=n;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<=n;i+=p)	prime[i]=false;
		}
	}	
    for(ll i=2;i<n+1;i++)
	{
		if(prime[i]) primes.push_back(i);
	} 
}
void prime_sieve(ll n)
{
	pf.assign(n+1,0);
	rep(i,n+1) pf[i]=i;
	for(ll i=2;i<=n;i++)
	{
		if (pf[i]==i)
		{
			for(ll j=i;j<=n;j+=i) pf[j]=i;
		}
	}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
// Always remember: if (condition) if (condition) statement; This doesn't work !!
// Always increase boundaries for global or frequency questions
// pow((ll)10,i) doesn't work sometimes. It is better to use multiple of 10 in arrays. Always remember this.
// delete values when defining global if there are multiple testcases
// don't try to be smart and make stupid mistakes
void solve()
{
	ll n;
	cin>>n;
	vll a(n),psum(n,0);
	rep(i,n) cin>>a[i];
	SS(a);
	rep(i,n)
	{
		if (!i) psum[i]=a[i];
		else psum[i]=psum[i-1]+a[i];
	}
	double ans=INF;
	ans=psum[n-1]*n;
	rep(i,n)
	{
		double a11=a[i];
		double p=a11/2;
		double q=p*n;
		double r=psum[n-1]-psum[i];
		ans=min(ans,q+r-2*p*(n-1-i));
	}
	cout.precision(20);
	cout<<ans/n<<endl;
}
int main()
{
	fast();
	ll T=1;
	//cin>>T;
	for(ll z=1;z<=T;z++) solve();
}
