Watermelon is a kindergarten teacher who needs to invent games for her energetic kids.
One day, she invented a new game. First, she gathered $$$n$$$ kids and drew a circle on the ground. Every kid is out of the circle initially. The $$$i$$$-th kid is assigned a number $$$a_i$$$. She then announced the rules:
Since the kids are cooperative, they will share the cookie after the game ends. Thus, they only care about the total number of the cookie that Watermelon will give out. Please help the kids determine the order in which they should be called so that they obtain the maximum number of cookies.
Note that if a circle contains no kids, it is considered to be divided into groups of size $$$x$$$ for any positive integer $$$x$$$.
The first line contains a positive integer $$$n$$$, the number of kids. The second line contains $$$n$$$ positive integers $$$a_1, a_2, \ldots, a_n$$$, representing the numbers assigned to each kid.
Output two lines. The first line is the maximum number of cookies they can receive. The second line is a permutation of size $$$n$$$, representing the order they should be called. The kids are numbered from $$$1$$$ to $$$n$$$.
If there are multiple solutions, you can output any of them.
4 1 1 3 4
4 2 1 3 4
8 1 2 3 4 1 2 3 4
6 1 2 3 4 7 8 5 6
In the second sample, the kids can guarantee to earn $$$6$$$ cookies if the teacher calls the kids in the following order $$$1, 2, 3, 4, 7, 8, 5, 6$$$: