N,K=list(map(int,input().split()))

A=list(map(int,input().split()))

mod=10**9+7

b=0

f=0

for i in range(N):

    for j in range(i+1,N):

        if A[i]>A[j]:

            #print(i,",",j)

            f+=1

           

            

for i in range(N):

    for j in range(N):

        if i==j:

            continue

        if A[i]>A[j]:

            b+=1



ans=f*K

tmp=((K-1)*K)//2

ans+=b*tmp

#ans = K * f + (b * K * (K - 1)) // 2

ans%=mod



print((int(ans)))
N,K=list(map(int,input().split()))

A=list(map(int,input().split()))

mod=10**9+7

b=0

f=0

for i in range(N):

    for j in range(i+1,N):

        if A[i]>A[j]:

            #print(i,",",j)

            f+=1

           

            

for i in range(N-1,-1,-1):

    for j in range(i-1,-1,-1):

        if A[i]>A[j]:

            b+=1



ans=f*((K+1)*K//2)+b*((K-1)*K//2)

ans%=mod

print(ans)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10**9 + 7
b = 0
f = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            # print(i,",",j)
            f += 1
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            b += 1
ans = f * K
tmp = ((K - 1) * K) // 2
ans += b * tmp
# ans = K * f + (b * K * (K - 1)) // 2
ans %= mod
print((int(ans)))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10**9 + 7
b = 0
f = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            # print(i,",",j)
            f += 1
for i in range(N - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        if A[i] > A[j]:
            b += 1
ans = f * ((K + 1) * K // 2) + b * ((K - 1) * K // 2)
ans %= mod
print(ans)

-for i in range(N): -    for j in range(N): -        if i == j: -            continue +for i in range(N - 1, -1, -1): +    for j in range(i - 1, -1, -1): -ans = f * K -tmp = ((K - 1) * K) // 2 -ans += b * tmp -# ans = K * f + (b * K * (K - 1)) // 2 +ans = f * ((K + 1) * K // 2) + b * ((K - 1) * K // 2) -print((int(ans))) +print(ans)