#C4420. Smallest Range Difference

    ID: 47957 Type: Default 1000ms 256MiB

Smallest Range Difference

Smallest Range Difference

You are given an array of integers. Your task is to find the smallest possible difference R - L such that every element in the array lies within the closed interval [L, R]. Mathematically, this difference is given by:

\( R - L = \max(arr) - \min(arr) \)

If the array is empty, output 0.

This problem will test your ability to process input from stdin and produce the correct result to stdout following the specified format.

inputFormat

The first line contains an integer N denoting the number of elements in the array. The second line contains N space-separated integers representing the array elements. If N is 0, then no further input is provided.

outputFormat

Output a single integer representing the smallest range difference, computed as ( R - L = \max(arr) - \min(arr) ). If the array is empty, output 0.## sample

5
4 1 7 3 9
8

</p>