#K84872. Minimize Task Difference Between Drones

    ID: 36516 Type: Default 1000ms 256MiB

Minimize Task Difference Between Drones

Minimize Task Difference Between Drones

You are given N tasks, each with an associated distance. There are also N drones that will each be assigned exactly one task. The goal is to find the minimum possible difference between the maximum and minimum task distances that the drones are assigned. In other words, you should calculate the difference between the largest and smallest distances.

The tasks are given as a list of integers. You must output the difference between the maximum and the minimum distance.

Note: Input and output are done via standard input and output (stdin and stdout).

Mathematically, if the sorted list of distances is \(d_1, d_2, \dots, d_N\), then the required result is \(d_N - d_1\).

inputFormat

The first line contains an integer N — the number of drones and tasks.

The second line contains N space-separated integers representing the distances for each task.

outputFormat

Output a single integer — the difference between the maximum and minimum task distances.

## sample
1
5
0