import sys

n,k=list(map(int,input().split()))

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

A=sorted(a)

shokou=[]

kousa=[]

m=10**9+7

for i in range(n):

  ct=0

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

    if a[i]>a[j]:ct+=1

  shokou.append(ct)

for i in range(n):

  kousa.append(A.index(a[i]))

ans=0

S=0

for i in range(n):

  S=(k*(2*shokou[i]+(k-1)*kousa[i]))//2

  S%=m

  ans+=S

print((ans%m))
n,k=list(map(int,input().split()))

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

A=sorted(l)

x=[];d=[]

m=10**9+7

for i in range(n):

  ct=0

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

    if l[i]>l[j]:ct+=1

  x.append(ct)

for i in range(n):

  d.append(A.index(l[i]))

ans=0

for i in range(n):

  ans+=((k*(2*x[i]+(k-1)*d[i]))//2)%m

print((ans%m))
import sys

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
A = sorted(a)
shokou = []
kousa = []
m = 10**9 + 7
for i in range(n):
    ct = 0
    for j in range(i + 1, n):
        if a[i] > a[j]:
            ct += 1
    shokou.append(ct)
for i in range(n):
    kousa.append(A.index(a[i]))
ans = 0
S = 0
for i in range(n):
    S = (k * (2 * shokou[i] + (k - 1) * kousa[i])) // 2
    S %= m
    ans += S
print((ans % m))

n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
A = sorted(l)
x = []
d = []
m = 10**9 + 7
for i in range(n):
    ct = 0
    for j in range(i + 1, n):
        if l[i] > l[j]:
            ct += 1
    x.append(ct)
for i in range(n):
    d.append(A.index(l[i]))
ans = 0
for i in range(n):
    ans += ((k * (2 * x[i] + (k - 1) * d[i])) // 2) % m
print((ans % m))

-import sys - -a = list(map(int, input().split())) -A = sorted(a) -shokou = [] -kousa = [] +l = list(map(int, input().split())) +A = sorted(l) +x = [] +d = [] -        if a[i] > a[j]: +        if l[i] > l[j]: -    shokou.append(ct) +    x.append(ct) -    kousa.append(A.index(a[i])) +    d.append(A.index(l[i])) -S = 0 -    S = (k * (2 * shokou[i] + (k - 1) * kousa[i])) // 2 -    S %= m -    ans += S +    ans += ((k * (2 * x[i] + (k - 1) * d[i])) // 2) % m