mod = 1000000007
_, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
count1, count2 = 0, 0
arr.each_with_index do |v, i|
  tmp_count1, tmp_count2 = 0, 0
  arr.each_with_index do |vv, ii|
    tmp_count1 += 1 if vv > v && ii < i
    tmp_count2 += 1 if vv > v
  end
  count1 += tmp_count1
  count2 += tmp_count2
end
ans = (count1 * k) % mod
ans = (ans + k * (k - 1) * count2 / 2) % mod
puts ans