input = gets.split("\s")
a = gets.split("\s").map(&:to_i)
n = input[0].to_i
k = input[1].to_i

b_self = 0
b_other = 0
dp = Array.new(n, 0)

n.times do |i|
  n.times do |j|
    if(a[i] > a[j])
      b_other += 1
      if(i < j)
        b_self += 1
      end
    end
  end
end

b_other *= (k * ((k-1) / 2)) #k-1 ... 1
b_self *= k

puts (b_other + b_self) % (10**9 + 7)
