#K50382. Minimum Climbing Height

    ID: 28852 Type: Default 1000ms 256MiB

Minimum Climbing Height

Minimum Climbing Height

Jerry is faced with a series of steps, each having a certain height. The objective is to determine the minimum total height that Jerry needs to climb in order to reach the top of the steps.

This is calculated by finding the difference between the highest and the lowest step. Mathematically, this can be expressed as:

$$\text{min\_total\_height} = \max(\text{heights}) - \min(\text{heights})$$

Note that the list of step heights is given in an order where the first number represents one extreme (typically the lowest) and the last number represents the other extreme (typically the highest), ensuring that the formula above correctly computes the required climb.

inputFormat

The input is provided via standard input (stdin) and is structured as follows:

  • The first line contains a single integer n, representing the number of steps.
  • The second line contains n space-separated integers, where each integer represents the height of a step.

outputFormat

The output should be a single integer written to standard output (stdout), which is the minimum total height Jerry needs to climb, computed as the difference between the maximum and minimum step heights.

## sample
5
1 3 6 2 8
7

</p>