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

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

ans=0

mod=10**9+7

inner=0

for i in range(n-1):

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

    if a[i]>a[j]:

      inner+=1

outer=0

for i in range(n):

  for j in range(n):

    if a[i]>a[j]:

      outer+=1

ans=inner*k+outer*k*(k-1)//2

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

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

ans=0

mod=10**9+7

inside=0

for i in range(n-1):

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

    if a[i]>a[j]:

      inside+=1

outside=0

for i in range(n):

  for j in range(n):

    if a[i]>a[j]:

      outside+=1

print(((k*inside+(k*(k-1)//2)*outside)%mod))



n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
inner = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            inner += 1
outer = 0
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            outer += 1
ans = inner * k + outer * k * (k - 1) // 2
print((ans % mod))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
inside = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            inside += 1
outside = 0
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            outside += 1
print(((k * inside + (k * (k - 1) // 2) * outside) % mod))

-inner = 0 +inside = 0 -            inner += 1 -outer = 0 +            inside += 1 +outside = 0 -            outer += 1 -ans = inner * k + outer * k * (k - 1) // 2 -print((ans % mod)) +            outside += 1 +print(((k * inside + (k * (k - 1) // 2) * outside) % mod))