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

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

mod = 10**9+7



C1 = [0]*n

C2 = [0]*n



for i in range(n):

    for j in range(n):

        if A[i] > A[j]:

            if j >= i:

                C1[i] += k*(k+1)//2

            else:

                C2[i] += (k-1)*k//2

ans = 0

#print(C1)

#print(C2)

for i in range(n):

    ans += C1[i]+C2[i]

print((ans%mod))

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

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

mod = 10**9+7



if n == 1:

    print((0))

    exit()



ans = 0

for i in range(n-1):

    for j in range(i, n):

        if A[i] < A[j]:

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

        elif A[i] > A[j]:

            ans += k*(k+1)//2

        else:

            pass

        ans %= mod

print(ans)

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

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

-C1 = [0] * n -C2 = [0] * n -for i in range(n): -    for j in range(n): -        if A[i] > A[j]: -            if j >= i: -                C1[i] += k * (k + 1) // 2 -            else: -                C2[i] += (k - 1) * k // 2 +if n == 1: +    print((0)) +    exit() -# print(C1) -# print(C2) -for i in range(n): -    ans += C1[i] + C2[i] -print((ans % mod)) +for i in range(n - 1): +    for j in range(i, n): +        if A[i] < A[j]: +            ans += (k - 1) * k // 2 +        elif A[i] > A[j]: +            ans += k * (k + 1) // 2 +        else: +            pass +        ans %= mod +print(ans)