You are given a permutation *p*. Calculate the total number of inversions in all permutations that lexicographically do not exceed the given one.

As this number can be very large, print it modulo 1000000007 (10<sup class="upper-index">9</sup> + 7).
The first line contains a single integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">6</sup>) — the length of the permutation. The second line contains *n* distinct integers *p*<sub class="lower-index">1</sub>, *p*<sub class="lower-index">2</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*).
print("_RANDOM_GUESS_1690504523.7858384")# 1690504523.7858589