#include <bits/stdc++.h>
using namespace std;

int main()
{
  const int mod = 1000000007;
  long n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  long s = 0, t = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a.at(i) > a.at(j)) s++;
      if (a.at(i) != a.at(j)) t++;
    }
  }
  long l = (k - 1) % 2 == 0 ? (k - 1) / 2 : (k - 1 + mod) / 2;
  s = k * (s + l * t % mod) % mod;
  cout << s << endl;
}
