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

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

div = 1000000007

s = 0

ss = 0



for i, a in enumerate(A):

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

        if a > A[j]:

            s += 1



for i in A:

    for j in A:

        if i > j:

            ss += 1



print((((s * K) + (ss * K * (K-1) // 2)) % div))

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

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

div = 1000000007

s = 0

ss = 0



for i, a in enumerate(A):

    for j in A[i+1:]:

        if a > j:

            s += 1



for i in A:

    for j in A:

        if i > j:

            ss += 1



print((((s * K) + (ss * K * (K-1) // 2)) % div))

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

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
div = 1000000007
s = 0
ss = 0
for i, a in enumerate(A):
    for j in A[i + 1 :]:
        if a > j:
            s += 1
for i in A:
    for j in A:
        if i > j:
            ss += 1
print((((s * K) + (ss * K * (K - 1) // 2)) % div))

-    for j in range(i + 1, N): -        if a > A[j]: +    for j in A[i + 1 :]: +        if a > j: