#include<bits/stdc++.h>
using namespace std;
long long n,m,a[2010],ans;
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++)
		for (int j=i+1;j<n;j++)
			if (a[i]>a[j]) ans++;
	ans*=m;ans%=1000000007;
	for (int i=0;i<n;i++){
		long long num=0;
		for (int j=0;j<n;j++) if (a[i]>a[j]) num++;
		ans=(ans+num*((m*(m-1)/2)%1000000007))%1000000007;
	}
	cout<<ans<<endl;
	return 0;
}