#K62462. Smallest Absolute Difference
Smallest Absolute Difference
Smallest Absolute Difference
Given a list of (n) integers, your task is to find the smallest absolute difference between any two distinct numbers in the list.
Formally, for any two different elements (a) and (b) in the list, the absolute difference is defined as (|a - b|). If any duplicate elements are present, then the smallest absolute difference is (0) because (|a - a| = 0).
Your solution should be both correct and efficient, as (n) can be very large.
inputFormat
The first line of input contains a single integer (n) (with (2 \leq n \leq 10^5)), the number of integers in the list. The second line contains (n) space-separated integers.
outputFormat
Output a single integer representing the smallest absolute difference between any pair of distinct integers in the list.## sample
5
1 3 6 9 10
1