Codeforces Round 572 (Div. 1)
D
Make Equal
Codeforces
3100
原题
← CE →
翻译中…

You are given $n$ numbers $a_1, a_2, \dots, a_n$. In one operation we can add to any one of those numbers a nonnegative integer power of $2$.

翻译中…

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

翻译中…

Input

翻译中…

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

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 10^{17}$).

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

In the second example, we can apply the operation $3$ times: add $8$ to first $2$, add $8$ to second $2$, add $2$ to $8$, making all numbers equal to $10$. It can be proved that we can't make all numbers equal in less than $3$ operations.

翻译中…

样例

Input #1
4
228 228 228 228
Output #1
0
InputCopy OutputCopy
Input #2
3
2 2 8
Output #2
3
InputCopy OutputCopy
题目信息
题号
1188D
时间限制
4 s
内存限制
256 MB
标签
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。