CF1188D.Make Equal

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given nn numbers a1,a2,,ana_1, a_2, \dots, a_n . In one operation we can add to any one of those numbers a nonnegative integer power of 22 .

What is the smallest number of operations we need to perform to make all nn numbers equal? It can be proved that under given constraints it doesn't exceed 101810^{18} .

输入格式

The first line contains a single integer nn ( 1n1051 \le n \le 10^5 ).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai10170 \le a_i \le 10^{17} ).

输出格式

Output exactly one integer — the smallest number of operations we need to perform to make all nn numbers equal.

输入输出样例

  • 输入#1

    4
    228 228 228 228
    

    输出#1

    0
  • 输入#2

    3
    2 2 8
    

    输出#2

    3

说明/提示

In the first example, all numbers are already equal. So the needed number of operation is 00 .

In the second example, we can apply the operation 33 times: add 88 to first 22 , add 88 to second 22 , add 22 to 88 , making all numbers equal to 1010 . It can be proved that we can't make all numbers equal in less than 33 operations.

首页