function Main(arg) {
 
    var N = arg.split("\n")[0].split(" ")[0]-0;
    var K = arg.split("\n")[0].split(" ")[1]-0;
    var A = arg.split("\n")[1].split(" ");
    var B = [];

    var ans = 0;
    for (var i = 0; i < N-1; i++) {
        var a = A[i] - 0;
        for (var j = i + 1; j < N; j++){
            var b = A[j] - 0;
            if (a > b) {
                ans++;
            }
        }
    }
    B.push(ans);

    ans = 0;
    for (var i = 0; i < N; i++) {
        var a = A[i] - 0;
        for (var j = 0; j < N; j++){
            var b = A[j] - 0;
            if (a > b) {
                ans++;
            }
        }
    }
    B.push(ans);

    ans = (B[0] * K) % (Math.pow(10, 9)+7);
    ans += (B[1] * ((K * (K - 1)) / 2)) % (Math.pow(10, 9)+7);

    console.log(ans%(Math.pow(10, 9)+7));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));