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

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

inner_count=0

other_count=0

for i in range(n):

  for j in range(n):

    if i==j or i>j:

      pass

    else:

      if A[i]>A[j]:

        inner_count+=1

for x in range(n):

  for y in range(n):

    if A[x]>A[y]:

      other_count+=1

inner_count = inner_count*k

other_count = other_count*(k*(k-1)//2)

print(((inner_count+other_count)%(10**9+7)))
N,K = list(map(int,input().split()))

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

tmp = 0

tmp2 = 0

ans = 0

MOD = 10**9+7



for i in range(N):

  for j in range(i,N):

    if i == j:

      pass

    else:

      if A[i] > A[j]:

        tmp += 1

  for k in range(N):

    if A[i] > A[k]:

      tmp2 += 1  

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

  ans %= MOD

  tmp = 0

  tmp2 = 0

print(ans)
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
inner_count = 0
other_count = 0
for i in range(n):
    for j in range(n):
        if i == j or i > j:
            pass
        else:
            if A[i] > A[j]:
                inner_count += 1
for x in range(n):
    for y in range(n):
        if A[x] > A[y]:
            other_count += 1
inner_count = inner_count * k
other_count = other_count * (k * (k - 1) // 2)
print(((inner_count + other_count) % (10**9 + 7)))

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

-n, k = list(map(int, input().split())) +N, K = list(map(int, input().split())) -inner_count = 0 -other_count = 0 -for i in range(n): -    for j in range(n): -        if i == j or i > j: +tmp = 0 +tmp2 = 0 +ans = 0 +MOD = 10**9 + 7 +for i in range(N): +    for j in range(i, N): +        if i == j: -                inner_count += 1 -for x in range(n): -    for y in range(n): -        if A[x] > A[y]: -            other_count += 1 -inner_count = inner_count * k -other_count = other_count * (k * (k - 1) // 2) -print(((inner_count + other_count) % (10**9 + 7))) +                tmp += 1 +    for k in range(N): +        if A[i] > A[k]: +            tmp2 += 1 +    ans += tmp2 * K * (K - 1) // 2 + tmp * K +    ans %= MOD +    tmp = 0 +    tmp2 = 0 +print(ans)