fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val A = listOfInt()
    var ans1 = ModInt(0)
    for (n in 0 until N-1) {
        for (m in n+1 until N) {
            if (A[n] > A[m]) {
                ans1 += 1
            }
        }
    }
    ans1 = ans1 * K
    var ans2 = ModInt(0)
    for (n in 0 until N) {
        for (m in 0 until N) {
            if (A[n] > A[m]) {
                ans2 += 1
            }
        }
    }
    ans2 *= K
    ans2 *= (K - 1)
    ans2 /= 2
    println(ans1 + ans2)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
data class ModInt(private var v: Long) {
    companion object {
        private const val MOD = 1000000007L
    }
    init {
        if (v >= MOD) v %= MOD
    }
    operator fun plus(other: ModInt): ModInt {
        val x = v + other.v
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }
    operator fun plus(other: Int): ModInt {
        val x = v + other.toLong()
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }
    operator fun minus(other: ModInt): ModInt {
        val x = v + MOD - other.v
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }
    operator fun times(other: ModInt): ModInt {
        return ModInt(v * other.v % MOD)
    }
    operator fun times(other: Int): ModInt {
        return ModInt(v * other.toLong() % MOD)
    }
    operator fun div(other: ModInt): ModInt {
        return ModInt(v * calc(other.v, MOD - 2) % MOD)
    }
    operator fun div(other: Int): ModInt {
        return ModInt(v * calc(other.toLong(), MOD - 2) % MOD)
    }
    private fun calc(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2L == 0L) {
            val d = calc(a, b / 2)
            return d * d % MOD
        }
        return a * calc(a, b - 1) % MOD
    }
    override fun toString(): String {
        return v.toString()
    }
}