#include <bits/stdc++.h>
using namespace std;
const int maxn=2123;
long long mod=1e9+7;
int n,a[maxn],K;
long long res;
int main()
{
    scanf("%d%d",&n,&K);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]);
    for (int i=1;i<=n;++i) {
        for (int j=1;j<=i;++j) if (a[j]>a[i]) res=(res+K)%mod;
        for (int j=1;j<=n;++j) if (a[j]>a[i]) res=(res+1ll*K*(K-1)/2)%mod;
    }
    cout<<res<<endl;
    return 0;
}
