#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
 
int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N+10);
  for(int i=0;i<N;i++)cin >> A[i];
  ll ans=0;
  for(int i=0;i<N;i++){
    ll cnt=0,cnt2=0;
    for(int j=0;j<N;j++){
      if(A[i]>A[j]){cnt++;}
      if(A[i]>A[j] && i<j)cnt2++;
    }
    ll memo=((K-1)*K/2%mod*cnt%mod+K*cnt2%mod)%mod;
    ans=(ans+memo)%mod;
  }
  cout << ans << endl;
}