#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> tot_num(50);
int GetInv(const vector<int> &perm) {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (perm[i] > perm[j]) {
        ++ans;
      }
    }
  }
  return ans;
}
void Calc(vector<int> &perm, int k) {
  if (k == 0) {
    ++tot_num[GetInv(perm)];
    return;
  }
  for (auto l = perm.begin(); l != perm.end(); ++l) {
    for (auto r = l + 1; r != perm.end() + 1; ++r) {
      reverse(l, r);
      Calc(perm, k - 1);
      reverse(l, r);
    }
  }
}
int main() {
  int k;
  cin >> n >> k;
  vector<int> perm(n);
  for (int i = 0; i < n; ++i) {
    cin >> perm[i];
  }
  Calc(perm, k);
  int ans = 0;
  int sum = 0;
  for (int i = 0; i < 50; ++i) {
    ans += i * tot_num[i];
    sum += tot_num[i];
  }
  printf("%.10lf\n", static_cast<double>(ans) / sum);
}
