#include <bits/stdc++.h>
#define ulli unsigned long long int
#define MAXN 500500
using namespace std;
ulli a[MAXN];

inline ulli busplus(int i,int k)
{
    if((a[i]>>k)&1)return 0;
    ulli z = 1;
    z=z<<k;
    return z-(a[i]%(z));
}
inline ulli busminus(int i,int k)
{
    if((a[i]>>k)&1)return 0;
    ulli z = 1;
    z=z<<k;
    if (a[i]<z) return ULONG_LONG_MAX;
    return a[i]%z+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    ///cin.tie(0);

    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];

    ///if(n&1)///neparno
    {
        ulli s=ULONG_LONG_MAX;
        for(int j=0;j<64;j++)
        {
            ulli sx=0;
            for(int i=0;i<n;i++)sx+=min(busplus(i,j),busminus(i,j));
            if(sx<s)s=sx;
        }
        cout<<">"<<s;
    }
    /*else
    {
        cout<<"...";
    }*/
    return 0;
}