#P5926. Minimum Absolute Difference Between Two Closest Distinct Numbers

    ID: 19151 Type: Default 1000ms 256MiB

Minimum Absolute Difference Between Two Closest Distinct Numbers

Minimum Absolute Difference Between Two Closest Distinct Numbers

Given a list of n integers, your task is to find the smallest absolute difference between any two distinct numbers from the list. The two numbers considered must not be equal. Note that the "closest" means with the minimum absolute difference.

Example:
For the list [4, 9, 1, 32, 13], one possible pair is (1, 4) and their absolute difference is |1 - 4| = 3, which is the minimum among all pairs of distinct numbers.

inputFormat

The input consists of two lines:

  1. The first line contains a single integer n (n ≥ 2) representing the number of integers.
  2. The second line contains n space-separated integers.

outputFormat

Output a single integer which is the minimum absolute difference between any two distinct numbers from the list.

sample

5
4 9 1 32 13
3