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

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

cnt = 0

l = []

for i in range(n):

    for j in range(n):

        if a[i] > a[j]:

            cnt += (k + 1) * k // 2 if j > i else k * (k - 1) // 2

print((cnt % 1000000007))
n, k = list(map(int, input().split()))

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

mod = 10 ** 9 + 7

cnt = 0

l = []

for i in range(n):

    for j in range(n):

        if a[i] > a[j]:

            cnt += (k + 1) * k // 2 if j > i else k * (k - 1) // 2

            cnt %= mod

print((cnt % mod))
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
l = []
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            cnt += (k + 1) * k // 2 if j > i else k * (k - 1) // 2
print((cnt % 1000000007))

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

+mod = 10**9 + 7 -print((cnt % 1000000007)) +            cnt %= mod +print((cnt % mod))