#C14000. Smallest Difference Pair
Smallest Difference Pair
Smallest Difference Pair
You are given an array of integers. Your task is to find the two elements in the array that have the smallest absolute difference. In the event of multiple pairs with the same smallest absolute difference, output the pair that appears first when scanning the array from left to right. If the array has fewer than two elements, output 'None None'.
The absolute difference between two numbers (a) and (b) is defined as (|a - b|).
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers representing the array elements.
outputFormat
Output the two elements (in the order they appear in the array) that have the smallest absolute difference, separated by a space. If there is no valid pair (i.e. if (n < 2)), output "None None".## sample
4
3 8 15 17
15 17
</p>