#K55952. Minimum Absolute Difference
Minimum Absolute Difference
Minimum Absolute Difference
You are given an array of integers. Your task is to compute the minimum absolute difference between any two distinct elements in the array. Formally, for an array \(a_1, a_2, \ldots, a_n\) with \(n \ge 1\), you need to find
[ \min_{1 \leq i < j \leq n} |a_i - a_j| ]
Note that if the array contains fewer than two elements, the answer is defined to be 0.
Input Format: The input is read from standard input. The first line contains an integer \(n\) (the number of elements in the array). The second line contains \(n\) space-separated integers.
Output Format: Print a single integer representing the minimum absolute difference between any two elements in the array.
Example:
Input: 4 3 8 15 17</p>Output: 2
inputFormat
The input is provided via standard input. The first line contains a single integer \(n\) indicating the number of elements. The second line contains \(n\) space-separated integers representing the array elements.
outputFormat
Output a single integer which is the minimum absolute difference between any two distinct elements of the array. If \(n < 2\), output 0.
## sample4
3 8 15 17
2