def tasu(a):

  out = (a*(a-1))//2 + a

  return out%(10**9 + 7)

    

  

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

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

count = 0

count1 = 0



for i in range(N):

  for j in range(N):

    if i == j:

      continue

    elif (i<j) & (A_list[i] > A_list[j]):

      count += 1

    elif (i>j) & (A_list[i] > A_list[j]):

      count1 += 1



ans = (tasu(K) * count) + (tasu(K-1) * count1) 

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

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

same = 0

diff = 0

 

for i in range(N):

  for j in range(N):

    if A_list[i] > A_list[j]:

      if i < j:

        same += 1

        diff += 1

      elif i>j:

        diff += 1

 

ans = (same*K) + (diff*((K * (K-1))//2))

print((ans%(10**9 + 7)))
def tasu(a):
    out = (a * (a - 1)) // 2 + a
    return out % (10**9 + 7)


N, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))
count = 0
count1 = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        elif (i < j) & (A_list[i] > A_list[j]):
            count += 1
        elif (i > j) & (A_list[i] > A_list[j]):
            count1 += 1
ans = (tasu(K) * count) + (tasu(K - 1) * count1)
print((ans % (10**9 + 7)))

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

-def tasu(a): -    out = (a * (a - 1)) // 2 + a -    return out % (10**9 + 7) - - -count = 0 -count1 = 0 +same = 0 +diff = 0 -        if i == j: -            continue -        elif (i < j) & (A_list[i] > A_list[j]): -            count += 1 -        elif (i > j) & (A_list[i] > A_list[j]): -            count1 += 1 -ans = (tasu(K) * count) + (tasu(K - 1) * count1) +        if A_list[i] > A_list[j]: +            if i < j: +                same += 1 +                diff += 1 +            elif i > j: +                diff += 1 +ans = (same * K) + (diff * ((K * (K - 1)) // 2))