Tima recently found an array $$$a$$$ of $$$n$$$ elements.
Being a powerful individual himself, he believes that his array should also be powerful.
An array is considered powerful if there exists some integer $$$d$$$ such that every element of the array is a power of $$$d$$$ $$$(1,\ d,\ d^2,\ d^3,\ \ldots)$$$. For example, $$$[8, 1, 1, 32]$$$ is powerful, and $$$[6, 7, 46, 343]$$$ is not.
In one operation, he can decrease or increase any element of the array by one.
What is the minimal number of operations required to make his array powerful?
The first line contains one integer $$$n$$$ $$$(1 \le n \le 10^5)$$$ — length of the array.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(1 \le a_i \le 10 ^{12})$$$ — elements of the array.
Output the minimal number of operations required to make the array powerful.
48 1 1 32
0
46 7 46 343
4
32 253 59149
111
| Name |
|---|


