local n,k=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local mod=1000000007
local A=0
local B=0
local counter=0
for i=1,n do
    for j=1,n do
        if a[i]>a[j] and i<j then
            A=A+1
        end
        if a[i]>a[j] then
            B=B+1
        end
    end
end
local counterA=A*k%mod
local counterB=(k*(k-1)//2%mod)*B%mod
print((counterA+counterB)%mod)