#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  long k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  int inner = 0;
  int outer = 0;

  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      if(a[i] > a[j]){
        inner++;
      }else if (a[i] < a[j]){
        outer++;
      }
    }
  }
  
  cout << ((inner + outer) * (k * (k - 1) / 2 % 1000000007) + inner * k) % 1000000007 << endl;
  return 0;
}
