You have an array with N elements. Initially, each element is 0. You can perform the following operations

Increment operation : choose one element of the value by one.

Doubling operation : Double the value of each element

You are given a int desired array containing N elements. Compute and return the smallest possible number of operations needed to change the array from all zeros to desired array.

Sample Test Case 1 :

Input : {2,1}

Output : 3

One of the optimal solutions is to apply increment operations to element 0 twice and then to element 1 once. Total number of operations is 3.

Sample Test Case 2 :

Input : {16,16,16}

Output : 7

The optimal solution looks as follows First, apply as increment operation to each element. Then apply the doubling operation four time. Total number of operations is 3+4=7.

Sample Test Case 3 :

Input : {100}

Output : 9

Sample Test Case 4 :

Input : {0,0,1,0,1}

Output : 2

Some elements in desired Array may be zeros.

Sample Test Case 5 :

Input : {123,234,345,456,567,678}

Output : 40.