def internal(a)
    a.each_with_index.inject(0) do |sum, (ai, i)|
        sum += a[i+1..-1].count{|aj| ai > aj}
    end
end

def external(a)
    a.inject(0) do |sum, ai|
        sum += a.count{|aj| ai > aj}
    end
end

N, K = gets.split.map &:to_i
A = gets.split.map &:to_i
p (K * internal(A) + (K * (K - 1) / 2) * external(A)) % (10**9 + 7)