#include <bits/stdc++.h>
using namespace std;
using ldouble = long double;
const int N = 110;
int n, k;
int p[N];
ldouble pp[N][N];
ldouble a[N][N];
void geta() {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      a[i][j] = p[i] > p[j];
    }
  }
}
void getpp() {
  int tot = 1ll * n * (n + 1) / 2;
  for (int l = 1; l <= n; ++l) {
    for (int r = l; r <= n; ++r) {
      for (int i = l, j = r; i < j; ++i, --j) {
        pp[i][j] += 1.0 / tot;
        pp[j][i] += 1.0 / tot;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    ldouble tmp = 0;
    for (int j = 1; j <= n; ++j) {
      tmp += pp[i][j];
    }
    pp[i][i] = 1 - tmp;
  }
}
void go() {
  ldouble c[N][N];
  memset(c, 0, sizeof(c));
  ldouble p_one = 2.0 / n / (n + 1);
  for (int l = 1; l <= n; ++l) {
    for (int r = l; r <= n; ++r) {
      for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j)
          if (i != j) {
            int x = i, y = j;
            if (x <= r && x >= l) x = l + r - x;
            if (y <= r && y >= l) y = l + r - y;
            c[x][y] += p_one * a[i][j];
          }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      a[i][j] = c[i][j];
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", p + i);
  }
  geta();
  getpp();
  while (k--) {
    go();
  }
  ldouble ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      ans += a[i][j];
    }
  }
  printf("%.12Lf\n", ans);
  return 0;
}
