#include <bits/stdc++.h>
using namespace std;
int N, K, p[111];
double ans;
void solve(int dp) {
  if (dp == K) {
    for (int i = 0; i < N; i++)
      for (int j = i + 1; j < N; j++)
        if (p[i] > p[j]) ans += 1;
    return;
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      reverse(p + i, p + j);
      solve(dp + 1);
      reverse(p + i, p + j);
    }
  }
}
int main() {
  double res[111][111];
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", &p[i]);
  solve(0);
  for (int i = 0; i < K; i++) ans /= N * (N + 1) / 2;
  printf("%.15lf\n", ans);
  return 0;
}
