Depot 1

Time limit: 5 seconds

Problem

There is a straight street going from west to east. There are n shops s1, s2, ..., sn, sorted in west to east order. The positioni pi of a shop si is specified by its distance (in meters) from the west end. s1 is at the west end, hence p1 = 0. No two shops have the same position and pi > 0 for all i > 1.

We will select one of the shop as a depot. Goods are first transfered to the depot and then distributed to all other shops on the street. Assume si is selected as the depot. To distribute goods to sj, the cost is |pj - pi|, i.e., the distance between them. The total cost of the distribution is the sum of cost over all shops. Notice that the cost of distributing goods to the depot si = |pi-pi| = 0.

This question requires you to find the minimum total cost of the distribution.

Input

The input consists of a number of test cases. Each test case starts with an integer n on a single line. Then the second line contains n integers, corresponding to p1, p2, ..., pn. We have 1 ≤ n ≤ 200, p1 = 0 and 1 ≤ p1 < p2 < ... < pn < 10,000. The last test case starts with an integer 0. Do not process it.

Output

For each test case, print an integer corresponding to the minimum total cost of distribution.

Sample Input

4
0 2 100 101
5
1 3 5 7 9
0

Sample Output

199
12

Author

Chan Ho Leung