#abc307g. [abc307_g]Approximate Equalization
[abc307_g]Approximate Equalization
Problem Statement
You are given an integer sequence of length : .
Takahashi can perform the following two operations any number of times, possibly zero, in any order.
- Choose an integer such that , and decrease by and increase by .
- Choose an integer such that , and increase by and decrease by .
Find the minimum number of operations required to make the sequence satisfy the following condition:
- for any pair of integers between and , inclusive.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print a single line containing the minimum number of operations required to make the sequence satisfy the condition in the problem statement.
Sample Input 1
3
2 7 6
Sample Output 1
4
You can make satisfy the condition with four operations as follows.
- Choose , and increase by and decrease by , making .
- Choose , and increase by and decrease by , making .
- Choose , and increase by and decrease by , making .
- Choose , and increase by and decrease by , making .
This is the minimum number of operations required, so print .
Sample Input 2
3
-2 -5 -2
Sample Output 2
2
You can make satisfy the condition with two operations as follows:
- Choose , and decrease by and increase by , making .
- Choose , and increase by and decrease by , making .
This is the minimum number of operations required, so print .
Sample Input 3
5
1 1 1 1 -7
Sample Output 3
13
By performing the operations appropriately, with operations you can make , which satisfies the condition in the problem statement. It is impossible to satisfy it with or fewer operations, so print .