CF558C.Amr and Chemistry

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment.

Amr has nn different types of chemicals. Each chemical ii has an initial volume of aia_{i} liters. For this experiment, Amr has to mix all the chemicals together, but all the chemicals volumes must be equal first. So his task is to make all the chemicals volumes equal.

To do this, Amr can do two different kind of operations.

  • Choose some chemical ii and double its current volume so the new volume will be 2ai2a_{i}
  • Choose some chemical ii and divide its volume by two (integer division) so the new volume will be

Suppose that each chemical is contained in a vessel of infinite volume. Now Amr wonders what is the minimum number of operations required to make all the chemicals volumes equal?

输入格式

The first line contains one number nn ( 1<=n<=1051<=n<=10^{5} ), the number of chemicals.

The second line contains nn space separated integers aia_{i} ( 1<=ai<=1051<=a_{i}<=10^{5} ), representing the initial volume of the ii -th chemical in liters.

输出格式

Output one integer the minimum number of operations required to make all the chemicals volumes equal.

输入输出样例

  • 输入#1

    3
    4 8 2
    

    输出#1

    2
  • 输入#2

    3
    3 5 6
    

    输出#2

    5

说明/提示

In the first sample test, the optimal solution is to divide the second chemical volume by two, and multiply the third chemical volume by two to make all the volumes equal 44 .

In the second sample test, the optimal solution is to divide the first chemical volume by two, and divide the second and the third chemical volumes by two twice to make all the volumes equal 11 .

首页