#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class IncrementAndDoubling { public:
int getMin(vector <int> d)
{
int cnt = 0;
for(;;++cnt)
{
for(auto& di : d)
if(di%2 == 1)
++cnt, di--;
if(count(d.begin(), d.end(), 0) == d.size())
break;
for(auto& di : d)
di /= 2;
}
return cnt;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, IncrementAndDoubling().getMin(desiredArray));}
int main(){
CASE(0)
int desiredArray_[] = {2, 1};
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = 3;
END
CASE(1)
int desiredArray_[] = {16, 16, 16};
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = 7;
END
CASE(2)
int desiredArray_[] = {100};
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = 9;
END
CASE(3)
int desiredArray_[] = {0, 0, 1, 0, 1};
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = 2;
END
CASE(4)
int desiredArray_[] = {123, 234, 345, 456, 567, 789};
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = 40;
END
CASE(5)
int desiredArray_[] = {7,5,8,1,8,6,6,5,3,5,5,2,8,9,9,4,6,9,4,4,1,9,9,2,8,4,7,4,8,8,6,3,9,4,3,4,5,1,9,8,3,8,3,7,9,3,8,4,4,7};
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = 84;
END
/*
CASE(6)
int desiredArray_[] = ;
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = ;
END
CASE(7)
int desiredArray_[] = ;
vector <int> desiredArray(desiredArray_, desiredArray_+sizeof(desiredArray_)/sizeof(*desiredArray_));
int _ = ;
END
*/
}
// END CUT HERE