Permutations
Sasha and Fedya are playing an intriguing game with n dice, each marked with a unique number from 1 to n. They have drawn n cells in a row on a piece of paper and follow these rules to play:
Initially, the first player places some of the dice on the cells. Then, the second player places the remaining dice on the empty cells. After all the dice are placed, the first player performs the following actions: he checks the number on the last die (let's call this number a) and reverses the order of the last a dice. The first player continues this process until the last die shows the number 1.
For instance, consider a scenario with five dice. If the first player places the second and third dice in the third and fifth positions, resulting in the sequence "..3.2", the second player might complete the arrangement as "41352". In this setup, the first player would need to make five moves: "41325", "52314", "54132", "54123", "54321", at which point the game concludes.
Sasha has made the first move. Your task is to assist Fedya in arranging the dice so that Sasha is required to make the maximum possible number of moves.
Input
The input file begins with the number n (1 ≤ n ≤ 25). The following n numbers represent the placement of the dice after Sasha's move. A 0 indicates an empty cell, while a number from 1 to n specifies the die in that cell. There are no more than 10 zeros in the input.
Output
On the first line of the output, print the maximum number of moves Sasha will need to make. On the second line, print n numbers from 1 to n, where the i-th number represents the die in the i-th cell after Fedya's move. If there are multiple optimal solutions, you may print any one of them.