#include <iostream> #include <queue> #include <map> #include <set> #include <cmath> #include <cstring> #include <algorithm> #include <iomanip> #include <stack> #include <numeric> #include <ctime> #include <string> #include <bitset> #include <unordered_map> #include <unordered_set> using namespace std; using ll = long long; const ll N = 1e5 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f; int n; multiset<int>st; void solve() { cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; st.insert(x); } ll ans = 0; while (*st.begin() != *st.rbegin()) { //最大的不等于最小的 int a = *st.begin(), b = *st.rbegin(); st.erase(st.begin()); auto it = st.find(b); st.erase(it); while (b > a) { b /= 2; ans++; } st.insert(a), st.insert(b); } cout << ans << '\n'; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int t = 1; //cin>>t; while (t--) { solve(); } return 0; }