Minimum Cost Sort
You are given n integers wi(i=0,1,...,n−1) to be sorted in ascending order. You can swap two integers wi and wj. Each swap operation has a cost, which is the sum of the two integers wi+wj. You can perform the operations any number of times.
Write a program which reports the minimal total cost to sort the given integers.