We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.  Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.  Find the inversion number of B, modulo 10^9 + 7.  Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.
N,K=input().split()
N,K=int(N),int(K)
A=input().split()

A=[int(N) for N in A]

prev=0
foll=0
for i in range(N):
    print('Ai',A[i])
    for j in range(i):
        if A[i]>A[j]:
            prev+=1
    for j in range(i,N):
        if A[i]>A[j]:
            foll+=1
    print(foll)

a = (K*(K-1)//2)%(10**9+7)
b = foll*K%(10**9+7)
u= (prev+foll)*a+b
print(u%(10**9+7))
N,K=input().split()
N,K=int(N),int(K)
A=input().split()

A=[int(N) for N in A]

prev=0
foll=0
for i in range(N):
    for j in range(i):
        if A[i]>A[j]:
            prev+=1
    for j in range(i,N):
        if A[i]>A[j]:
            foll+=1

a = (K*(K-1)//2)%(10**9+7)
b = foll*K%(10**9+7)
u= (prev+foll)*a+b
print(u%(10**9+7))