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



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



mod = 1000000007



# K = 2のときの初期値が必要

B = A * 2

syokiti_A = 0

syokiti_B = 0

for i in range(N):

    for j in range(i, N):

        if A[i] > A[j]:

            syokiti_A += 1



for i in range(N):

    for j in range(N):

        if i == j:

            continue

        if A[i] > A[j]:

            syokiti_B += 1



ans = (syokiti_A * K) % mod + (syokiti_B * K * (K-1) // 2) % mod

print((int(ans) % mod))

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



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



p = 0

q = 0

ans = 0

for i in range(N):

    for j in range(i, N):

        if A[i] > A[j]:

            p += 1



for i in range(N):

    for j in range(N):

        if A[i] > A[j]:

            q += 1



ans = (p * K) % 1000000007 + (q * K * (K-1) // 2) % 1000000007



print((ans % 1000000007))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 1000000007
# K = 2のときの初期値が必要
B = A * 2
syokiti_A = 0
syokiti_B = 0
for i in range(N):
    for j in range(i, N):
        if A[i] > A[j]:
            syokiti_A += 1
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            syokiti_B += 1
ans = (syokiti_A * K) % mod + (syokiti_B * K * (K - 1) // 2) % mod
print((int(ans) % mod))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
p = 0
q = 0
ans = 0
for i in range(N):
    for j in range(i, N):
        if A[i] > A[j]:
            p += 1
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            q += 1
ans = (p * K) % 1000000007 + (q * K * (K - 1) // 2) % 1000000007
print((ans % 1000000007))

-mod = 1000000007 -# K = 2のときの初期値が必要 -B = A * 2 -syokiti_A = 0 -syokiti_B = 0 +p = 0 +q = 0 +ans = 0 -            syokiti_A += 1 +            p += 1 -        if i == j: -            continue -            syokiti_B += 1 -ans = (syokiti_A * K) % mod + (syokiti_B * K * (K - 1) // 2) % mod -print((int(ans) % mod)) +            q += 1 +ans = (p * K) % 1000000007 + (q * K * (K - 1) // 2) % 1000000007 +print((ans % 1000000007))