Preparando MOJI
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.
Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to:
Find the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence.
The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$).
The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$).
Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence.
3 1 3 2
1
3 1000000000 1000000000 1000000000
1999982505
In the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$.