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

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



P = 10**9+7



ans = 0

for i in range(N):

    for j in range(N):

        if i == j:

            continue

        if A[i] > A[j]:

            if i < j:

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

                ans %= P

            else:

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

                ans %= P

print(ans)

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

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



P = 10**9+7



ans1 = 0

ans2 = 0

for i in range(N):

    for j in range(N):

        if i == j:

            continue

        if A[i] > A[j]:

            if i < j:

                ans1 += 1

            else:

                ans2 += 1



K1 = (K*(K+1)//2)%P

K2 = (K*(K-1)//2)%P



ans = (ans1*K1+ans2*K2)%P



print(ans)

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

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
P = 10**9 + 7
ans1 = 0
ans2 = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            if i < j:
                ans1 += 1
            else:
                ans2 += 1
K1 = (K * (K + 1) // 2) % P
K2 = (K * (K - 1) // 2) % P
ans = (ans1 * K1 + ans2 * K2) % P
print(ans)

-ans = 0 +ans1 = 0 +ans2 = 0 -                ans += K * (K + 1) // 2 -                ans %= P +                ans1 += 1 -                ans += K * (K - 1) // 2 -                ans %= P +                ans2 += 1 +K1 = (K * (K + 1) // 2) % P +K2 = (K * (K - 1) // 2) % P +ans = (ans1 * K1 + ans2 * K2) % P