str = gets.split
N,K = str[0].to_i, str[1].to_i
a = Array.new(N)
b = Array.new(2001,0)
c = 0
d = 0
mod = 10**9 + 7
str = gets.split
for i in 0...N do
    n = str[i].to_i
    a[i] = n
    b[n] += 1
end
for i in 1..2000 do
    b[i] += b[i-1]
end
for i in 1..2000 do
    d += (b[i]-b[i-1])*b[i-1]
end

x = 0
y = 1
while x < N-1
    y = x + 1
    while y < N
        if a[x] > a[y]
            c += 1
        end
        y += 1
    end
    x += 1
end

answer = (c * K) % mod
answer += (( K * (K-1) * d)/2)%mod
answer = answer % mod

puts answer