#include<bits/stdc++.h>
using namespace std;
const int N=2005,mod=1e9+7;
unsigned long long a[N],n,k,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		unsigned long long s1=0,s2=0;
		for(int j=1;j<=n;j++)
		{
			if(a[i]>a[j])
			{
				if(j<i) s1++;
				else s2++;
			}
		}
		ans=(ans+k*(k-1)/2%mod*s1%mod)%mod;
		ans=(ans+k*(k+1)/2%mod*s2%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}
