The largest average
On the board, there are n integers, each labeled from 1 to n
. You can select any two numbers, erase them, and replace them with a new number that is their arithmetic mean. This new number is assigned the label n + 1. You repeat this process: choose two numbers, compute their mean, and replace them with a new number labeled n + 2, and so on. This continues until only one number remains on the board. The goal is to maximize the value of this final number.
Your task is to determine the sequence of actions that will result in the largest possible final number.
Input
The first line contains an integer n
(1 ≤ n ≤ 10^5
). The second line contains n integers initially written on the board. Each number is within the range from -10000
to 10000.
Output
Output n - 1 lines, each containing two integers separated by a space. These integers represent the labels of the numbers chosen at each step.