#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int ninv(vector<int>& p) {
  int res = 0, n = p.size();
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      if (p[j] < p[i]) ++res;
  return res;
}
vector<pii> generate(int n) {
  vector<pii> res;
  for (int i = 0; i < n; ++i)
    for (int j = i; j < n; ++j) res.push_back({i, j});
  return res;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n, 0);
  for (int i = 0; i < n; ++i) cin >> p[i];
  vector<pii> pool(generate(n));
  int ps = pool.size(), m = 1;
  for (int i = 0; i < k; ++i) m *= ps;
  long double res = 0;
  for (int i = 0; i < m; ++i) {
    vector<int> pp(p);
    for (int j = 0, cur = i; j < k; ++j) {
      auto pcur = pool[cur % ps];
      cur /= ps;
      int a = pcur.first, b = pcur.second;
      reverse(pp.begin() + a, pp.begin() + b + 1);
    }
    res += (double)ninv(pp);
  }
  res /= (long double)m;
  cout << fixed << setprecision(12);
  cout << res << endl;
  return 0;
}
