#include <cstdio>
#define orz 1000000007
using namespace std;
int n,a[2005];
long long b[2005];
int main(void){
	int i,j;
	long long ans=0,k,cnt,re=0;
	scanf("%d%lld",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		for(j=0,cnt=0;j<n;j++){
			if(a[j]<a[i]){
				cnt++;
				if(i<j) b[i]++;
			}
		}
		ans=(ans+cnt)%orz;
		re=(re+b[i])%orz;
	}
	re=re*k%orz;
	k=((k-1)*k/2)%orz;
	ans=ans*k%orz;
	ans=(ans+re)%orz;
	printf("%lld",ans);
	return 0;
}