#C6746. Maximum Maze Path Complexity

    ID: 50540 Type: Default 1000ms 256MiB

Maximum Maze Path Complexity

Maximum Maze Path Complexity

You are given a maze path composed of m cells. Each cell is associated with an integer value. The complexity of the maze path is defined as:

\( Complexity = 2 \times (\max(b) - \min(b)) \)

where \(b\) is the list of cell values.

Your task is to compute the maximum possible complexity of the maze path.

Input: The first line contains an integer \(m\) representing the number of cells. The second line contains \(m\) integers separated by spaces, representing the cell values.

Output: Output a single line containing the maximum possible complexity.

inputFormat

The input is given via stdin and consists of two lines:

  • The first line contains an integer \(m\) — the number of cells in the maze path.
  • The second line contains \(m\) space-separated integers \(b_1, b_2, \dots, b_m\) which represent the cell values.

outputFormat

Output a single integer — the maximum complexity of the maze path computed as \(2 \times (\max(b) - \min(b))\).

The output should be printed to stdout.

## sample
5
1 3 5 7 2
12

</p>