local MOD = 1000000007
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})
local N, K = read.nnl()
local A = {}
for i=1,N do
    A[i] = read.n()
end

local T = {}
local L = {}
for i=1,N do
    local p = A[i]
    L[i] = 0
    for j=1,i-1 do
        local add = A[j] < p and 1 or 0
        L[i] = L[i] + add
    end
    T[i] = 0
    for j=i+1,N do
        local add = A[j] < p and 1 or 0
        T[i] = T[i] + add
    end
end

local SUM1 = (K * (K + 1) // 2) % MOD
local SUM2 = (K * (K - 1) // 2) % MOD

local ans = 0
for i=1,N do
    ans = ans + (SUM1 * T[i] % MOD)
    ans = ans % MOD
    ans = ans + (SUM2 * L[i] % MOD)
    ans = ans % MOD
end
print(ans)