n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
inner = 0
for i in 1.upto(n - 1)
    for j in 0.upto(i - 1)
        if a[j] > a[i] then
            inner += 1
        end
    end
end
a1 = a.sort
lesscount = 0
outer = 0
for i in 1.upto(n - 1)
    if a1[i - 1] < a1[i] then
        lesscount = i
    end
    outer += lesscount
end
puts (k * inner + (k * (k - 1) / 2) * outer) % (1_000_000_000 + 7)
