Introduction - If you have any usage issues, please Google them yourself
Description n elements (1,2 ,..., n) there are n! Different order. This n! Were arranged according to lexicographic order, and numbered 0,1, ..., n!-1. With the numbering of each sequence value for the dictionary. For example, when n = 3 when six different lexicographic order of value are as follows: Missions: given n and n elements (1,2 ,..., n) an array to calculate the lexicographic order of value , as well as lexicographic order with the next. Input Line 1 is the number of elements n (n <15). The next one line is n elements (1,2 ,..., n) of an array. Output the first line is the lexicographic value, line 2 is arranged according to lexicographic order of the next. Sample Input 82 6 4 5 8 1 7 3Sample Output 82272 6 4 5 8 3 1 7