#K35402. Pairing Players to Minimize Skill Difference

    ID: 25523 Type: Default 1000ms 256MiB

Pairing Players to Minimize Skill Difference

Pairing Players to Minimize Skill Difference

You are given a list of integers representing the skill levels of players. Your task is to pair the players such that the absolute difference between the skill levels in each pair is minimized. To achieve this, you should first sort the list of skill levels in non-decreasing order and then form pairs using adjacent elements. If there is an odd number of players, the last player (with the highest skill level) remains unpaired.

Input Format: The first line contains a single integer n — the number of players. The second line contains n space-separated integers representing the skill levels of the players.

Output Format: Print the resulting pairs or single player, each on a new line. For each pair, print the two skill levels separated by a space, and for a lone player, print the skill level by itself.

Example:

Input:
5
3 8 2 7 5

Output: 2 3 5 7 8

</p>

Note: The pairing is formed after sorting the array. For example, the list [3, 8, 2, 7, 5] becomes [2, 3, 5, 7, 8] after sorting, which results in the pairs (2, 3), (5, 7) and the unpaired element 8.

inputFormat

The first line contains an integer n, the number of players. The second line contains n space-separated integers which represent the skill levels of the players.

outputFormat

For each pair formed, output a line containing two space-separated integers. If there is an unpaired player, output that player's skill level on a separate line.

## sample
5
3 8 2 7 5
2 3

5 7 8

</p>