#C13061. Find the Closest Pair

    ID: 42558 Type: Default 1000ms 256MiB

Find the Closest Pair

Find the Closest Pair

You are given an array of integers. Your task is to identify the pair of elements with the smallest absolute difference, i.e. the pair (a, b) for which \(|a-b|\) is minimized.

If there are multiple pairs with the same smallest absolute difference, return the pair that appears first in the array based on the leftmost occurrence of the first element of the pair.

The array will contain at least two elements.

inputFormat

The first line contains an integer n (n ≥ 2), the number of elements in the array. The second line contains n integers separated by spaces.

outputFormat

Output two integers separated by a space representing the pair with the smallest absolute difference. If multiple pairs match the criteria, output the one that appears first in the array.

## sample
4
1 2 3 4
1 2