Nikhil and Civil Engineering

0

0 votes
Medium
Problem

Nikhil recently started working in Samsung C&T alongside Samyak and Paras.

The very first project given to Nikhil was to construct wall of N length (in meter) . Nikhil being excited started working on project without reading specific details of project and ended up building the wall with different height of each 1 meter length segment. (For example, if project was to build wall of length 3 meter, He built 1st meter of height 8, 2nd meter of height 16 and 3rd meter of height 32.) It may be possible that he did his job perfectly.

Now, Samyak and Paras being project partner came to know about blunder made by Nikhil. The main problem is to make all segments' height equal. They can perform following two operation on one segment:

1) demolish - This operation would half the height of segment (consider integer division)

2) construct - This operation would double the height of segment

Each operation takes one day to complete.

Now, time is running out for Nikhil,Samyak and Paras to complete this project so they can not randomly perform these operations and they want to complete this project in minimum days So, they went to Jaydeep for help as he is best programmer.

Jaydeep built the logic immediately but could not code it so can you help him?

INPUT FORMAT

First line consist of length 1<= N <= 10^5

Second line consist of N integer, Ai (1<= N <= 10^5) integer represent height of i-th segment.

OUTPUT FORMAT

print answer , minimum days required to complete project

Time Limit: 1
Memory Limit: 255
Source Limit:
Explanation

Day 1 : Construct segment 1 so new height is 16

Day 2 : Demolish segment 3 so new height is 16

Editor Image

?