#C10579. Smallest Difference in Plant Species

    ID: 39799 Type: Default 1000ms 256MiB

Smallest Difference in Plant Species

Smallest Difference in Plant Species

You are given a collection of plant species numbers represented as integers. Your task is to calculate the smallest difference between any two numbers in the dataset.

More formally, given an integer (n) and a list of (n) integers (a_1, a_2, \dots, a_n), you need to determine the minimum value of (a_j - a_i) for any indices (i, j) where (1 \leq i < j \leq n). The list of numbers is unsorted and may contain duplicates.

For example, if the input is 5 and 8 1 4 2 9, the smallest difference is (1) (which occurs between the numbers 1 and 2).

inputFormat

The first line contains an integer (n) which denotes the number of plant species. The second line contains (n) space-separated integers representing the plant species numbers.

outputFormat

Output a single integer which is the smallest difference between any two of the given plant species numbers.## sample

5
8 1 4 2 9
1