Number of permutation#2388

Number of permutation

1 second
64 megabytes
Very easy

Given a permutation of numbers from to . Find its number in the lexicographical order.

Input

The first line contains the integer (1 \leq n \leq 12). The next line contains the permutation of numbers.

Output

Print the number of the permutation in lexicographical order.

Examples

Example 1

Loading
Loading