#include<cstdio>
const int MOD = int(1E9) + 7;
const int MAXN = 2000;
int A[MAXN + 5], N, K;
int main() {
	scanf("%d%d", &N, &K);
	for(int i=0;i<N;i++) scanf("%d", &A[i]);
	int ans = 0;
	for(int i=0;i<N;i++)
		for(int j=i+1;j<N;j++)
			if( A[i] > A[j] ) ans++;
	ans = 1LL*ans*K%MOD;
	int tmp = 0;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if( A[i] > A[j] ) tmp++;
	ans = (ans + 1LL*K*(K-1)/2%MOD*tmp%MOD)%MOD;
	printf("%d\n", ans);
}