A sequence of length is sorted if for every .
Count the distinct sequences obtainable by rearranging the elements of that are not sorted.
Two sequences are equal when their elements agree at every position. Different ways of moving elements that produce the same sequence are counted only once. For example, produces , , and . Two of these are not sorted, so the answer is .
The input is given in the following format.
Print the number of distinct sequences satisfying the condition.
The first line contains the integer . The second line contains space-separated integers .
| 5 | 34 | No additional constraints. |