mod = 10 ** 9 + 7
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
numl = Array.new(n)
numr = Array.new(n)

n.times do |i|
    c = 0
    d = 0
    (i + 1).upto(n - 1) do |j|
        c += 1 if a[i] > a[j]
    end

    (i - 1).downto(0) do |j|
        d += 1 if a[i] > a[j]
    end

    numl[i] = c
    numr[i] = d
end

ans = 0
n.times do |i|
    ans += numl[i] * k * (k + 1) / 2
    ans += numr[i] * k * (k - 1) / 2
    ans %= mod
end

puts ans