N,K = gets.split(" ").map(&:to_i);
a = gets.split(" ").map(&:to_i);
ainv = a.reverse
inv = 0
count = 0
for i in 0..N-2
    
    for j in i+1..N-1
        if a[i] > a[j]
            count += 1
        end
    end
end
inv += K*(K+1)/2*count
count = 0
for i in 0..N-2
    
    for j in i+1..N-1
        if ainv[i] > ainv[j]
            count += 1
        end
    end
end
inv += K*(K-1)/2*count

out = inv % (10**9+7)
puts out
    
