#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 2019
const LL MOD=1e9+7;

int n;
LL k;
LL ans1,ans2;
int a[N];

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
		if(a[i]>a[j]) ans1++;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		if(a[i]>a[j]) ans2++;
	cout<<(ans1*k+k*(k-1)/2%MOD*ans2)%MOD<<'\n';
	
	return 0;
}