﻿ Fuzhou University OnlineJudge ﻿
Problem 1716 Sort Problem

## Problem Description

There are a array of numbers,they are Incompatible with each other.CDGG want to sort them in ascending order.Each exchange he can choose any two of this numbers and exchange their position.Each exchange has a cost,it equals to the sum of the two numbers.Given a array of numbers,can you help CDGG to calculate the minimum total cost.

## Input

The input consists of several test cases. Each case contains two line,the first line contains a number n indicates the number of the integer array.The second line contains n integer ai.All integer is smaller than 1000.The input ends with a 0.

## Output

For each case,first output “Case t: ”,t indicates the case number,then output a integer,indicates the minimum total cost.After each case,please output a blank line.

## Sample Input

3 3 2 1 4 8 1 2 4 5 1 8 9 7 6 6 8 4 5 3 2 7 0

## Sample Output

Case 1: 4 Case 2: 17 Case 3: 41 Case 4: 34

## Source

FZU 2009 Summer Training Qualification -- Hero Revival 1

Submit  Back  Status  Discuss
﻿