Switchback#8652

Switchback

0.2 seconds
64 megabytes
Medium

Visitors are drawn to attractions like "Roller Coasters" primarily because of the thrilling height differences. The park has acquired modules, each with a specific height M_i, which can be assembled into a single attraction. Your task is to arrange these modules in such a way that the total height difference, calculated as:

P = |M_1 - M_2| + |M_2 - M_3| + \ldots + |M_{N-1} - M_N|

is maximized.

Input

The input begins with a line containing the number of modules (4 \leq N \leq 100). The next line contains natural numbers representing the heights of the modules M_1, M_2, \ldots, M_N (1 \leq M_i \leq 1000). These numbers are separated by spaces.

Output

Output the maximum possible total height difference .

Examples

Example 7

Loading
Loading