SP9386 MAIN112 - Re-Arrange II

Description

For a sequence of N integers, A1, A2, ..... AN We can calculate the stability factor P, as P = sum of all (abs(A $ _{i} $ -A $ _{i-1} $ )\*C\[i\]) where 2

Input Format

N/A

Output Format

For each test case, print the minimum possible value of P considering all permutations of the given numbers.