#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
const long long Mod=1e9+7;
long long n,k,a[2020],ans,sum1,sum2;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			if(a[j]>a[i]) sum1++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[j]>a[i]) sum2++;
		}
	}
	ans=sum1*k%Mod;
	ans+=(k*(k-1)/2%Mod)*sum2%Mod;
	ans%=Mod;
	printf("%lld\n",ans);
	return 0;
}