C. Powerful Tima
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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?

Input

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

Output the minimal number of operations required to make the array powerful.

Examples
Input
4
8 1 1 32
Output
0
Input
4
6 7 46 343
Output
4
Input
3
2 253 59149
Output
111