#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const bool db = false;
int p[7], k, n;
int cnt = 0, tot = 0;
int inv() {
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) ans += (p[i] > p[j]);
  return ans;
}
void calc(int it) {
  if (it == 0) {
    tot += inv();
    ++cnt;
    return;
  }
  for (int l = 1; l <= n; ++l) {
    for (int r = l; r <= n; ++r) {
      int op[7];
      for (int k = 1; k <= n; ++k) op[k] = p[k];
      reverse(p + l, p + r + 1);
      calc(it - 1);
      for (int k = 1; k <= n; ++k) p[k] = op[k];
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) cin >> p[i];
  calc(k);
  cout.precision(15);
  cout << fixed << 1.0 * tot / cnt << "\n";
  getchar();
  getchar();
  return 0;
}
