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

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

MOD = 10**9+7



ans = 0

for i in range(N):

    for j in range(N):

        if A[i] > A[j]:

            if i > j:

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

            elif i < j:

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

            ans %= MOD



print(ans)

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

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

ans = 0

MOD = 10**9+7

for i in range(N):

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

        if A[i] > A[j]:

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

        elif A[i] < A[j]:

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



        ans %= MOD



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

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

+ans = 0 -ans = 0 -    for j in range(N): +    for j in range(i + 1, N): -            if i > j: -                ans += k * (k - 1) // 2 -            elif i < j: -                ans += k * (k + 1) // 2 -            ans %= MOD +            ans += k * (k + 1) // 2 +        elif A[i] < A[j]: +            ans += k * (k - 1) // 2 +        ans %= MOD