The program which take the length of array, reference array, input array and values of variables in the input array. It counts the lowest effort to sort the input array according to the reference array. The way of sorting is changing places of two single variables. The cost of the single changing is the sum of values of each variable.
The input is a four-line file with values separated by a space, run by command: program.py < text.txt