B. Buy One Get One Free
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

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:

  • The kids must determine a permutation and submit it to her, she will call the kids one by one according to the permutation.
  • Once a kid is called, he will step into the circle. Then, let $$$a_i$$$ be the number assigned to this kid, all kids currently in the circle must divide themselves into groups of size $$$a_i$$$. Kids not in any group will be removed out of the circle. The kids can determine who to leave the circle, as long as the remaining kids in the circle can be divided into groups of size $$$a_i$$$.
  • The game ends when every kid has been called. A kid who has been removed out of the circle cannot be called again. When the game ends, each kid still in the circle receives a cookie as a reward.

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$$$.

Input

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.

  • $$$1 \leq n \leq 10000$$$
  • $$$1 \leq a_i \leq n$$$
Output

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.

Examples
Input
4
1 1 3 4
Output
4
2 1 3 4
Input
8
1 2 3 4 1 2 3 4
Output
6
1 2 3 4 7 8 5 6
Note

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$$$:

  1. In the first four steps, four kids are called and the kids always form exactly one group.
  2. In the fifth step, the teacher calls the $$$7$$$-th kid, since there are $$$5$$$ kids in the circle currently, $$$2$$$ kids are removed and the rest of them forms one group of size $$$3$$$.
  3. In the next step, the teacher calls the $$$8$$$-th kid, all the remaining kids form one group of size $$$4$$$.
  4. In the next step, the teacher calls the $$$5$$$-th kid, each of the kids forms one group of size $$$1$$$ and nobody will be removed.
  5. In the last step, the teacher calls the $$$6$$$-th kid, the kids will form three groups of size $$$2$$$. Since all kids have been called and there are $$$6$$$ kids remaining in the circle, the teacher gives $$$6$$$ cookies out.