#include <bits/stdc++.h> using namespace std; //minnum记录最小数,mincnt记录最小数个数,每输入一个数,就进行比较,知道输入的数==minnum //记输入为k,k>minnum时/2次数+1,k除以二,k<minnum时,minnum/2,次数加上mincnt,把之前处理过的全部/2 int main() { int n,mincnt=0,minnum=0,k,ans=0; cin>>n; for(int i=0;i<n;i++){ cin>>k; if(!i){ mincnt=1; minnum=k; continue; } while(minnum!=k){ if(k>minnum){ ans++; k/=2; }else if(k<minnum){ minnum/=2; ans+=mincnt; } } mincnt++; } cout<<ans; }