题目描述
Given N space separated integers. Your task is to arrange them such that the summation M of the absolute differences between every two adjacent numbers is maximum.
Input:
First line of the input contains an integer N.
Second line contains N space separated integers A_i.
Output:
Print the above described M.
Constraints:
1 ≤ N ≤ 1000.
1 ≤ A_i ≤ 10^{5}.
SAMPLE INPUT
3
1 2 7
SAMPLE OUTPUT
11
Explanation
One of the best arrangements is (1,7,2), M = |1 - 7| + |7 - 2| = 11
输入格式
见题面
输出格式
见题面
样例输入
3
1 2 7
SAMPLE
样例输出
11