Problem: Let's call a list of positive integers a power sequence if there is a positive integer , so that for every then .
Given a list of positive integers , you are allowed to:
- Reorder the list (i.e. pick a permutation of and change to ), then
- Do the following operation any number of times: pick an index and change to or (i.e. increment or decrement by ) with a cost of .
Find the minimum cost to transform into a power sequence.
Input Format: The first line contains an integer ().
The second line contains integers ().
Output Format: Print the minimum cost to transform into a power sequence.
Note: In the first example, we first reorder into , then increment to with cost to get a power sequence .