Problems
Number of permutation
Number of permutation
Given a permutation of n numbers from 1 to n. Find its number in the lexicographic order.
Input data
The first line contains the integer n~(1 \le n \le 12). The next line contains the permutation of n numbers.
Output data
Print the permutation number in lexicographical order.
Examples
Input example #1
3 2 1 3
Output example #1
3