import java.util.*

fun main(args: Array<String>) {
	val mod = 1000000007

	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val k = scanner.nextLong()

	val map = IntArray(2001){i -> 0}

	var cnt = 0L
	var max = 0
	for (i in 0..n-1){
		val a = scanner.nextInt()
		for (j in a+1..2000) cnt+=map[j]
		map[a]++
		max = Math.max(max, a)
	}
	cnt = (cnt*k)%mod
	var tmp = 0L
	for (i in max downTo 1){
		cnt = (cnt+tmp*map[i]*(((k-1)*k/2)%mod))%mod
		tmp += map[i]
	}

	println(cnt)
}