#K14456. Smallest Pumpkin Weight Range

    ID: 24138 Type: Default 1000ms 256MiB

Smallest Pumpkin Weight Range

Smallest Pumpkin Weight Range

Given an integer n representing the number of pumpkins and a list of n pumpkin weights, your task is to determine the smallest possible range between any two adjacent weights when the list is sorted. Formally, after sorting the weights in non-decreasing order as \(w_1, w_2, \dots, w_n\), you must compute

\(\min_{1 \le i < n} (w_{i+1} - w_i)\)

If n = 1, output 0.

inputFormat

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

  • The first line contains one integer \(n\) (\(1 \le n \le 10^5\)), the number of pumpkins.
  • The second line contains \(n\) space-separated integers representing the weights of the pumpkins.

outputFormat

Output a single integer representing the smallest range (i.e. the minimum difference between two adjacent weights in the sorted list) to standard output.

## sample
1
7
0

</p>