n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

ans1 = 0
ans2 = 0

(0..(n-1)).each do |i|
  e = a[i]
  ((i+1)..(n-1)).each do |j|
    f = a[j]
    # p [e,f].join(',')
    if e > f
      ans1 += 1
    end
  end
end

a.each do |e|
  a.each do |f|
    # p [e,f].join(',')
    if e > f
      ans2 += 1
    end
  end
end

# puts [ans1, ans2].join(', ')
# puts ans1 + ans2

mod = 10**9 + 7
ans = ans1 * k + ans2 * k * (k-1) /2
# puts ans
puts ans % mod