MOD_N = (10**9)+7

def main
  n, k = gets.chop.split.map(&:to_i)
  arr = gets.chop.split.map(&:to_i)

  res_p = 0
  res_n = 0
  0.upto(n-1) do |i|
    (i+1).upto(n-1) do |j|
      res_p += 1 if arr[i] > arr[j]
      res_n += 1 if arr[-i-1] > arr[-j-1]
    end
  end
  res = (res_p + res_n) * ((k * (k-1)) / 2) + (k * res_p)
  puts (res % MOD_N)
end


if __FILE__ == $0
  main
end