#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
ll n,k,a[2005];
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	ll ans=0;
	for(int i=1;i<=n;i++)
	  for(int j=i+1;j<=n;j++)
	    if(a[i]>a[j])ans+=k;
	ans%=MOD;
	for(int i=1;i<=n;i++)
	{
		ll num=0;
		for(int j=1;j<=n;j++)
		  if(a[i]>a[j])num++;
		ans+=k*(k-1)/2%MOD*num%MOD;
	}
	ans%=MOD;
	printf("%lld\n",ans);
	return 0;
}