#C3252. Find the Closest Pair

    ID: 46659 Type: Default 1000ms 256MiB

Find the Closest Pair

Find the Closest Pair

You are given a list of unique integers. Your task is to find a pair of integers (a, b) from the list such that:

  • a < b
  • There are no integers between a and b in the sorted order of the list.

In other words, when the array is sorted, find the adjacent pair with the smallest difference. If there are multiple pairs with the same difference, return the pair which appears first in the sorted order.

The answer should be printed as two space-separated integers from standard output.

Note: The input is given via standard input and the output must be written to standard output.

inputFormat

The first line contains an integer n, representing the number of integers in the list.

The second line contains n space-separated unique integers.

outputFormat

Output two integers separated by a space, representing the pair (a, b) such that a < b and they are adjacent in the sorted order with the minimum difference.

## sample
5
5 1 7 3 9
1 3