val MOD = 1000000007

fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val later = IntArray(n.toInt()){0}
    val whole = IntArray(n.toInt()){0}

    for (i in aa.indices) {
        for (j in i+1 until n.toInt()) {
            if (aa[j] < aa[i]) {
                later[i] += 1
            }
        }
        whole[i] = aa.count { it < aa[i] }
    }

    var cnt = 0L

    for (i in aa.indices) {
        cnt += later[i] * k
        cnt %= MOD
        cnt += whole[i] * ((((k-1) * k) / 2L) % MOD)
        cnt %= MOD
    }

    println(cnt)
}