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

 

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

tentou1=0

for i in range(N):

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

    if(a[i]>a[j]):

      tentou1+=1

stentou=0

for i in range(N):

  for j in range(N):

    if(a[i]>a[j]):

      stentou+=1

answer=int(tentou1*K + stentou*K*(K-1)//int(2))

print((answer%1000000007))

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



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

tentou1=0

for i in range(len(a)):

  for j in range(i+1,len(a)):

    if(a[i]>a[j]):

      tentou1+=1

a.sort()

a.reverse()

stentou=0

for i in range(len(a)):

  for j in range(i+1,len(a)):

    if(a[i]>a[j]):

      stentou+=1

answer=int(tentou1*K + int(stentou*K*(K-1)//2))

print((answer%1000000007))

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

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
tentou1 = 0
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        if a[i] > a[j]:
            tentou1 += 1
a.sort()
a.reverse()
stentou = 0
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        if a[i] > a[j]:
            stentou += 1
answer = int(tentou1 * K + int(stentou * K * (K - 1) // 2))
print((answer % 1000000007))

-for i in range(N): -    for j in range(i + 1, N): +for i in range(len(a)): +    for j in range(i + 1, len(a)): +a.sort() +a.reverse() -for i in range(N): -    for j in range(N): +for i in range(len(a)): +    for j in range(i + 1, len(a)): -answer = int(tentou1 * K + stentou * K * (K - 1) // int(2)) +answer = int(tentou1 * K + int(stentou * K * (K - 1) // 2))