#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#define ll long long
const ll mod=1000000007;
using namespace std;
int n,a[2005];
ll h[2005],g[2005],ans,m;
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			if(a[j]<a[i]){
				g[i]++;
				if(j>i)h[i]++;
			}
		ans=(ans+(h[i]*m)%mod)%mod;
		ans=(ans+(g[i]*((m*(m-1)/2)%mod))%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}