#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n;
long long k;
int a[2005];
long long ans,q;
int num,tot;
int book[2005];
int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		book[a[i]]++;
	}
	for(int i=1;i<=n;i++) 
		for(int j=i+1;j<=n;j++) if(a[i]>a[j]) num++;
	ans=k*num;
	ans%=mod;
	tot=n;
	for(int i=2000;i>0;i--) {
		tot-=book[i];
		q=(k-1)*k/2;
		q%=mod;
		q*=book[i]*tot;
		q%=mod;
		ans+=q;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}