#C5327. Minimum Additional Distance

    ID: 48964 Type: Default 1000ms 256MiB

Minimum Additional Distance

Minimum Additional Distance

You are given the positions of n spacecrafts along a one-dimensional line. Your task is to compute the minimum additional distance necessary to cover the smallest gap between any two consecutive spacecrafts once the positions are sorted in increasing order.

Note: The positions may be given in an unsorted order, and there might be duplicate positions. In the case where there is only one unique position or all positions are the same, the minimum gap is defined accordingly.

Input Format: The first line of input contains the integer n, representing the number of spacecrafts. The second line contains n space-separated integers indicating the positions of the spacecrafts.

Output Format: Output a single integer representing the minimum gap between any two adjacent spacecrafts when their positions are listed in sorted order. All input and output should be handled via STDIN and STDOUT.

The solution requires that you consider the ordered sequence of the positions and compute the minimum difference between any two consecutive elements.

inputFormat

The input consists of two lines:

  • The first line contains a single integer n (1 ≤ n ≤ 105), the number of spacecrafts.
  • The second line contains n space-separated integers representing the positions of the spacecrafts. The positions can be given in any order.

outputFormat

Output a single integer: the minimum difference between any two adjacent spacecraft positions after sorting them in increasing order.

## sample
5
1 3 7 10 15
2

</p>