N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

l = Array.new(N)
r = Array.new(N)

for i in 0...N
    l[i] = 0
    r[i] = 0
    for j in 0...N
        next if i == j
        next if a[i] <= a[j]

        if i > j
            l[i] += 1
        elsif i < j
            r[i] += 1
        end
    end
end

ans = 0
for i in 0...N
    ans += r[i] * K 
    ans %= 1000000007
    ans += (r[i] + l[i]) * (K * (K-1) / 2)
    ans %= 1000000007
end

puts ans
