#K83712. Closest Pair in a Sorted Array
Closest Pair in a Sorted Array
Closest Pair in a Sorted Array
You are given a sorted array of distinct integers. Your task is to find and output the two adjacent elements whose difference is the smallest among all adjacent pairs. If there are multiple pairs with the same minimum difference, choose the first such occurrence.
The answer should be printed as two space-separated integers.
Note: The input will be read from standard input (stdin) and the output must be printed to standard output (stdout).
Mathematically, if the sorted array is \(a_1, a_2, \dots, a_n\), you need to find index \(i\) such that \( (a_{i+1} - a_i) \) is minimized, and output \(a_i\) and \(a_{i+1}\).
inputFormat
The first line of input contains an integer \(n\) (\(n \ge 2\)), indicating the number of elements in the array. The second line contains \(n\) space-separated integers in ascending order.
outputFormat
Output two space-separated integers representing the pair with the smallest difference.
## sample5
1 3 4 8 13
3 4