#include<cstdio>
typedef long long LL;
const int MOD=1e9+7;
const int N=2005;
const int A=2005;

int n;
int a[N];
int cnt[N];
LL ans,k;

int main() {
	scanf("%d %lld",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		ans+=cnt[a[i]+1];
		for(int j=a[i];j>=0;j--)
			cnt[j]++;
	}
	ans=ans*k%MOD;
	LL tot=(k*(k-1)/2)%MOD;
	for(int i=1;i<=n;i++)
		ans=(ans+tot*cnt[a[i]+1])%MOD;
	printf("%lld\n",ans);
	return 0;
}