cswork / OAOpen practice workspace

IBMOA #56

Minimum Difference

Estimated EasyJudge-ready

Topics (AI-labelled)In-place Arrays

Given distinct integers, find all unordered pairs with the minimum absolute difference. In each pair the smaller number comes first, and all pairs are output in ascending order by the first item, then by the second.

Input

The first line contains n, and the second line contains distinct integers. 2≤n≤100000, −10^9≤value≤10^9.

Output

Output the number of pairs on the first line, followed by two integers per line in the specified order.

Example 1

Input:

5
-1 3 6 -5 0

Output:

1
-1 0

Example 2

Input:

5
6 5 4 3 7

Output:

4
3 4
4 5
5 6
6 7

Example 3

Input:

4
1 3 5 10

Output:

2
1 3
3 5

Example notes

The examples give only -1 0; 3 4, 4 5, 5 6, 6 7; and 1 3, 3 5 respectively. The wrong answer in the original site's first example has been corrected according to the statement body.

Editorial

Loading solution…