You are given items with distinct integer weights. Pair every item exactly once so that the sum of the absolute weight differences within the pairs is as small as possible. Any optimal pairing is accepted.
The first line contains one integer , the number of pairs to create. The second line contains distinct integers , the item weights.
Print lines. Each line must contain two 1-based indices of items forming one pair. Every index from through must appear exactly once, and the total pairing cost must be minimal.
All weights are distinct.
Input:
3
10 1 8 3 4 20
Output:
2 4
5 3
1 6
The pairs have weight differences , , and , for a total cost of , which is minimal.
Python, C++
Sample 1
Input
3 10 1 8 3 4 20
Output
2 4 5 3 1 6
The pairing has the minimum total cost of 16.